use of org.orcid.utils.solr.entities.OrcidSolrResults 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.OrcidSolrResults 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.OrcidSolrResults 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.OrcidSolrResults in project ORCID-Source by ORCID.
the class OrcidSearchManagerImplTest method multipleResultsForQuery.
private OrcidSolrResults multipleResultsForQuery() {
OrcidSolrResults orcidSolrResults = new OrcidSolrResults();
List<OrcidSolrResult> resultsList = new ArrayList<>();
orcidSolrResults.setResults(resultsList);
resultsList.add(getOrcidSolrResult("5678", new Float(37.2)));
resultsList.add(getOrcidSolrResult("6789", new Float(52.2)));
orcidSolrResults.setNumFound(2);
return orcidSolrResults;
}
use of org.orcid.utils.solr.entities.OrcidSolrResults in project ORCID-Source by ORCID.
the class OrcidSearchManagerImpl method findOrcidsByQuery.
@Override
public OrcidMessage findOrcidsByQuery(Map<String, List<String>> query) {
OrcidMessage orcidMessage = new OrcidMessage();
OrcidSearchResults searchResults = new OrcidSearchResults();
OrcidSolrResults orcidSolrResults = solrDao.findByDocumentCriteria(query);
searchResults.setNumFound(orcidSolrResults.getNumFound());
List<OrcidSolrResult> indexedOrcids = orcidSolrResults.getResults();
if (indexedOrcids != null && !indexedOrcids.isEmpty()) {
List<OrcidSearchResult> orcidSearchResults = buildSearchResultsFromPublicProfile(indexedOrcids);
searchResults.getOrcidSearchResult().addAll(orcidSearchResults);
}
orcidMessage.setOrcidSearchResults(searchResults);
return orcidMessage;
}
Aggregations