use of org.apache.solr.client.solrj.SolrQuery in project ORCID-Source by ORCID.
the class SolrIndexUpdater method retrieveLastModified.
public Date retrieveLastModified(String orcid) {
SolrQuery query = new SolrQuery();
query.setQuery(ORCID + ":\"" + orcid + "\"");
query.setFields(PROFILE_LAST_MODIFIED_DATE);
try {
QueryResponse response = solrServer.query(query);
List<SolrDocument> results = response.getResults();
if (results.isEmpty()) {
return null;
} else {
return (Date) results.get(0).getFieldValue(PROFILE_LAST_MODIFIED_DATE);
}
} catch (SolrServerException e) {
throw new NonTransientDataAccessResourceException("Error retrieving last modified date from SOLR Server", e);
}
}
use of org.apache.solr.client.solrj.SolrQuery in project ORCID-Source by ORCID.
the class OrgDisambiguatedSolrDaoImpl method findById.
@Override
public OrgDisambiguatedSolrDocument findById(Long id) {
SolrQuery query = new SolrQuery();
query.setQuery(ORG_DISAMBIGUATED_ID + ":" + id).setFields("*");
try {
QueryResponse queryResponse = solrServerReadOnly.query(query);
if (!queryResponse.getResults().isEmpty()) {
OrgDisambiguatedSolrDocument document = queryResponse.getBeans(OrgDisambiguatedSolrDocument.class).get(0);
return document;
}
} catch (SolrServerException se) {
String errorMessage = MessageFormat.format("Error when attempting to retrieve org {0}", new Object[] { id });
throw new NonTransientDataAccessResourceException(errorMessage, se);
}
return null;
}
use of org.apache.solr.client.solrj.SolrQuery in project ORCID-Source by ORCID.
the class AppContextSolrTest method testServerRunning.
@Test
@Ignore
public void testServerRunning() throws Exception {
SolrQuery solrQuery = new SolrQuery().setQuery("carberry");
QueryResponse response = solrServer.query(solrQuery);
assertNotNull(response);
}
use of org.apache.solr.client.solrj.SolrQuery in project ORCID-Source by ORCID.
the class FundingSubtypeSolrDaoImpl method getFundingTypes.
@Override
public List<OrgDefinedFundingTypeSolrDocument> getFundingTypes(String searchTerm, int firstResult, int maxResult) {
SolrQuery query = new SolrQuery();
query.setQuery("{!edismax qf='org-defined-funding-type^50.0 text^1.0' pf='org-defined-funding-type^50.0' mm=1 sort='score desc'}" + searchTerm + "*").setFields("*");
try {
QueryResponse queryResponse = solrServerReadOnly.query(query);
return queryResponse.getBeans(OrgDefinedFundingTypeSolrDocument.class);
} catch (SolrServerException se) {
String errorMessage = MessageFormat.format("Error when attempting to search for orgs, with search term {0}", new Object[] { searchTerm });
throw new NonTransientDataAccessResourceException(errorMessage, se);
}
}
use of org.apache.solr.client.solrj.SolrQuery 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);
}
Aggregations