Search in sources :

Example 1 with OrcidSolrResult

use of org.orcid.utils.solr.entities.OrcidSolrResult in project ORCID-Source by ORCID.

the class SolrDaoTest method searchByOrcid.

@Test
public void searchByOrcid() throws Exception {
    OrcidSolrResult firstOrcidResult = solrDao.findByOrcid(firstOrcid);
    assertNull(firstOrcidResult);
    OrcidSolrDocument secondOrcid = buildAndPersistSecondOrcid();
    OrcidSolrDocument firstOrcid = buildAndPersistFirstOrcid();
    firstOrcidResult = solrDao.findByOrcid(firstOrcid.getOrcid());
    assertFalse(secondOrcid.getOrcid().equals(firstOrcidResult.getOrcid()));
    assertEquals("1234-5678", firstOrcidResult.getOrcid());
}
Also used : OrcidSolrResult(org.orcid.utils.solr.entities.OrcidSolrResult) OrcidSolrDocument(org.orcid.utils.solr.entities.OrcidSolrDocument) Test(org.junit.Test)

Example 2 with OrcidSolrResult

use of org.orcid.utils.solr.entities.OrcidSolrResult in project ORCID-Source by ORCID.

the class SolrDaoTest method queryStringSearchGrant.

@Test
public void queryStringSearchGrant() throws Exception {
    OrcidSolrDocument secondOrcid = buildAndPersistSecondOrcid();
    String patentQueryString = "grant-numbers:grant-number02X%3A";
    OrcidSolrResults orcidSolrResults = solrDao.findByDocumentCriteria(patentQueryString, null, null);
    List<OrcidSolrResult> solrResultsList = orcidSolrResults.getResults();
    assertTrue(solrResultsList.size() == 1);
    assertEquals(secondOrcid.getOrcid(), solrResultsList.get(0).getOrcid());
}
Also used : OrcidSolrResult(org.orcid.utils.solr.entities.OrcidSolrResult) OrcidSolrDocument(org.orcid.utils.solr.entities.OrcidSolrDocument) OrcidSolrResults(org.orcid.utils.solr.entities.OrcidSolrResults) Test(org.junit.Test)

Example 3 with OrcidSolrResult

use of org.orcid.utils.solr.entities.OrcidSolrResult in project ORCID-Source by ORCID.

the class SolrDaoTest method queryStringSearchFamilyNameGivenName.

@Test
public void queryStringSearchFamilyNameGivenName() throws Exception {
    OrcidSolrResult orcidSolrDocument = solrDao.findByOrcid(firstOrcid);
    assertNull(orcidSolrDocument);
    orcidSolrDocument = solrDao.findByOrcid(secondOrcid);
    assertNull(orcidSolrDocument);
    OrcidSolrDocument profile1 = new OrcidSolrDocument();
    profile1.setOrcid(firstOrcid);
    profile1.setFamilyName("Bass");
    profile1.setGivenNames("Teddy");
    OrcidSolrDocument profile2 = new OrcidSolrDocument();
    profile2.setOrcid(secondOrcid);
    profile2.setFamilyName("Bass");
    profile2.setGivenNames("Terry");
    solrDao.persist(profile1);
    solrDao.persist(profile2);
    String familyNameGivenNameQuery = "given-names:teddy AND family-name:bass";
    OrcidSolrResults orcidSolrResults = solrDao.findByDocumentCriteria(familyNameGivenNameQuery, null, null);
    List<OrcidSolrResult> solrResultsList = orcidSolrResults.getResults();
    assertTrue(solrResultsList.size() == 1);
    assertEquals(firstOrcid, solrResultsList.get(0).getOrcid());
    String familyNameQueryRelaxed = "given-names:te* AND family-name:Bass";
    solrResultsList = solrDao.findByDocumentCriteria(familyNameQueryRelaxed, null, null).getResults();
    assertTrue(solrResultsList.size() == 2);
    assertEquals(firstOrcid, solrResultsList.get(0).getOrcid());
    assertEquals(secondOrcid, solrResultsList.get(1).getOrcid());
}
Also used : OrcidSolrResult(org.orcid.utils.solr.entities.OrcidSolrResult) OrcidSolrDocument(org.orcid.utils.solr.entities.OrcidSolrDocument) OrcidSolrResults(org.orcid.utils.solr.entities.OrcidSolrResults) Test(org.junit.Test)

Example 4 with OrcidSolrResult

use of org.orcid.utils.solr.entities.OrcidSolrResult in project ORCID-Source by ORCID.

the class SolrDaoImpl method findByDocumentCriteria.

@Override
public OrcidSolrResults findByDocumentCriteria(Map<String, List<String>> queryMap) {
    OrcidSolrResults orcidSolrResults = new OrcidSolrResults();
    List<OrcidSolrResult> orcidSolrResultsList = new ArrayList<>();
    orcidSolrResults.setResults(orcidSolrResultsList);
    SolrQuery solrQuery = new SolrQuery();
    for (Map.Entry<String, List<String>> entry : queryMap.entrySet()) {
        String queryKey = entry.getKey();
        List<String> queryVals = entry.getValue();
        solrQuery.add(queryKey, queryVals.get(0));
    }
    solrQuery.setFields(SCORE, ORCID);
    return querySolr(solrQuery);
}
Also used : OrcidSolrResult(org.orcid.utils.solr.entities.OrcidSolrResult) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Map(java.util.Map) SolrQuery(org.apache.solr.client.solrj.SolrQuery) OrcidSolrResults(org.orcid.utils.solr.entities.OrcidSolrResults)

Example 5 with OrcidSolrResult

use of org.orcid.utils.solr.entities.OrcidSolrResult in project ORCID-Source by ORCID.

the class OrcidSearchManagerImplTest method getSolrRes6789.

private OrcidSolrResult getSolrRes6789() {
    OrcidSolrResult solrResult = new OrcidSolrResult();
    solrResult.setOrcid("6789");
    solrResult.setRelevancyScore(new Float(52.2));
    return solrResult;
}
Also used : OrcidSolrResult(org.orcid.utils.solr.entities.OrcidSolrResult)

Aggregations

OrcidSolrResult (org.orcid.utils.solr.entities.OrcidSolrResult)28 OrcidSolrResults (org.orcid.utils.solr.entities.OrcidSolrResults)13 OrcidSolrDocument (org.orcid.utils.solr.entities.OrcidSolrDocument)11 ArrayList (java.util.ArrayList)9 Test (org.junit.Test)9 OrcidMessage (org.orcid.jaxb.model.message.OrcidMessage)8 OrcidSearchResult (org.orcid.jaxb.model.message.OrcidSearchResult)8 OrcidSearchResults (org.orcid.jaxb.model.message.OrcidSearchResults)6 BufferedReader (java.io.BufferedReader)2 IOException (java.io.IOException)2 Reader (java.io.Reader)2 Date (java.util.Date)2 SolrQuery (org.apache.solr.client.solrj.SolrQuery)2 SolrServerException (org.apache.solr.client.solrj.SolrServerException)2 QueryResponse (org.apache.solr.client.solrj.response.QueryResponse)2 SolrDocument (org.apache.solr.common.SolrDocument)2 DeactivatedException (org.orcid.core.exception.DeactivatedException)2 OrcidDeprecatedException (org.orcid.core.exception.OrcidDeprecatedException)2 OrcidSearchException (org.orcid.core.exception.OrcidSearchException)2 LockedException (org.orcid.core.security.aop.LockedException)2