Search in sources :

Example 1 with OrcidSolrResults

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());
}
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 2 with OrcidSolrResults

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

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);
}
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 4 with OrcidSolrResults

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;
}
Also used : OrcidSolrResult(org.orcid.utils.solr.entities.OrcidSolrResult) ArrayList(java.util.ArrayList) OrcidSolrResults(org.orcid.utils.solr.entities.OrcidSolrResults)

Example 5 with 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;
}
Also used : OrcidSearchResult(org.orcid.jaxb.model.message.OrcidSearchResult) OrcidSolrResult(org.orcid.utils.solr.entities.OrcidSolrResult) OrcidSearchResults(org.orcid.jaxb.model.message.OrcidSearchResults) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) OrcidSolrResults(org.orcid.utils.solr.entities.OrcidSolrResults)

Aggregations

OrcidSolrResults (org.orcid.utils.solr.entities.OrcidSolrResults)17 OrcidSolrResult (org.orcid.utils.solr.entities.OrcidSolrResult)15 ArrayList (java.util.ArrayList)10 OrcidMessage (org.orcid.jaxb.model.message.OrcidMessage)6 OrcidSearchResult (org.orcid.jaxb.model.message.OrcidSearchResult)6 OrcidSearchResults (org.orcid.jaxb.model.message.OrcidSearchResults)6 List (java.util.List)5 Test (org.junit.Test)5 FundingList (org.orcid.jaxb.model.message.FundingList)4 OrcidSolrDocument (org.orcid.utils.solr.entities.OrcidSolrDocument)4 Map (java.util.Map)3 NonTransientDataAccessResourceException (org.springframework.dao.NonTransientDataAccessResourceException)3 BufferedReader (java.io.BufferedReader)2 IOException (java.io.IOException)2 Reader (java.io.Reader)2 Arrays (java.util.Arrays)2 Date (java.util.Date)2 Collectors (java.util.stream.Collectors)2 Resource (javax.annotation.Resource)2 BaseTest (org.orcid.core.BaseTest)2