use of org.nextprot.api.solr.Query in project nextprot-api by calipho-sib.
the class SearchServiceImpl method sortAccessions.
@Override
public List<String> sortAccessions(QueryRequest queryRequest, Set<String> accessions) {
List<String> sortedAccessions = new ArrayList<String>();
try {
String queryString = "id:" + (accessions.size() > 1 ? "(" + Joiner.on(" ").join(accessions) + ")" : accessions.iterator().next());
queryRequest.setQuery(queryString);
Query query = queryBuilderService.buildQueryForSearchIndexes("entry", "pl_search", queryRequest);
SearchResult result = this.solrService.executeQuery(query);
List<Map<String, Object>> results = result.getResults();
for (Map<String, Object> res : results) {
String entry = (String) res.get("id");
sortedAccessions.add(entry);
}
} catch (SearchQueryException e) {
e.printStackTrace();
throw new NextProtException("Error when retrieving accessions");
}
return sortedAccessions;
}
use of org.nextprot.api.solr.Query in project nextprot-api by calipho-sib.
the class SolrServiceTest method shouldReturnResultsFromSparqlQuery.
@Test
public void shouldReturnResultsFromSparqlQuery() throws Exception {
QueryRequest qr = new QueryRequest();
qr.setMode("advanced");
qr.setQuality("gold");
qr.setSparqlEngine("Jena");
qr.setSparql("#Proteins phosphorylated and located in the cytoplasm\nselect distinct ?entry where {\n ?entry :isoform ?iso.\n ?iso :keyword / :term cv:KW-0597.\n ?iso :cellularComponent /:term /:childOf cv:SL-0086.\n}");
Query q = queryBuilderService.buildQueryForSearch(qr, "entry");
SearchResult result = service.executeQuery(q);
assertTrue(result.getFound() >= 5636);
}
use of org.nextprot.api.solr.Query in project nextprot-api by calipho-sib.
the class SolrServiceTest method shouldReturnResultsFromSharedProteinList.
@Test
public void shouldReturnResultsFromSharedProteinList() throws Exception {
QueryRequest qr = new QueryRequest();
qr.setQuality("gold");
qr.setListId("Y7JPIEVH");
qr.setListOwner("Guest");
Query q = queryBuilderService.buildQueryForSearch(qr, "entry");
SearchResult result = service.executeQuery(q);
assertEquals(1, result.getFound());
}
use of org.nextprot.api.solr.Query in project nextprot-api by calipho-sib.
the class SolrServiceTest method shouldReturnResultsFromSharedQueryList.
@Test
public void shouldReturnResultsFromSharedQueryList() throws Exception {
QueryRequest qr = new QueryRequest();
qr.setQuality("gold");
qr.setMode("advanced");
qr.setQueryId("3K8W9PJT");
Query q = queryBuilderService.buildQueryForSearch(qr, "entry");
SearchResult result = service.executeQuery(q);
assertTrue(result.getFound() >= 5636);
}
use of org.nextprot.api.solr.Query in project nextprot-api by calipho-sib.
the class SolrServiceTest method shoulReturnSomeEntriesWhenStopWordsAreIncludedInQuery.
@Test
public void shoulReturnSomeEntriesWhenStopWordsAreIncludedInQuery() throws Exception {
QueryRequest qr;
Query q;
SearchResult result;
long numFound;
qr = new QueryRequest();
qr.setQuery("insulin");
q = queryBuilderService.buildQueryForSearch(qr, "entry");
result = service.executeQuery(q);
numFound = result.getFound();
// we should get some results
assertTrue(numFound > 0);
qr = new QueryRequest();
qr.setQuery("insulin in the of");
q = queryBuilderService.buildQueryForSearch(qr, "entry");
result = service.executeQuery(q);
numFound = result.getFound();
// we should ALSO get some results
assertTrue(numFound > 0);
}
Aggregations