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());
}
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());
}
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());
}
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);
}
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;
}
Aggregations