Search in sources :

Example 16 with Query

use of org.nextprot.api.solr.Query in project nextprot-api by calipho-sib.

the class SolrServiceTest method shoulReturnSomeTermsWhenStopWordsAreIncludedInQuery.

@Test
public void shoulReturnSomeTermsWhenStopWordsAreIncludedInQuery() throws Exception {
    QueryRequest qr;
    Query q;
    SearchResult result;
    long numFound;
    qr = new QueryRequest();
    qr.setQuery("brain");
    q = queryBuilderService.buildQueryForSearch(qr, "term");
    result = service.executeQuery(q);
    numFound = result.getFound();
    // we should get some results
    assertTrue(numFound > 0);
    qr = new QueryRequest();
    qr.setQuery("brain in the of");
    q = queryBuilderService.buildQueryForSearch(qr, "term");
    result = service.executeQuery(q);
    numFound = result.getFound();
    // we should ALSO get some results
    assertTrue(numFound > 0);
}
Also used : QueryRequest(org.nextprot.api.solr.QueryRequest) Query(org.nextprot.api.solr.Query) SearchResult(org.nextprot.api.solr.SearchResult) WebUnitBaseTest(org.nextprot.api.web.dbunit.base.mvc.WebUnitBaseTest) Test(org.junit.Test)

Example 17 with Query

use of org.nextprot.api.solr.Query in project nextprot-api by calipho-sib.

the class SolrServiceTest method shouldReturnResultsFromSimpleGoldEntryQuery.

@Test
public void shouldReturnResultsFromSimpleGoldEntryQuery() throws Exception {
    QueryRequest qr = new QueryRequest();
    qr.setQuality("GOLD");
    qr.setQuery("MSH6");
    Query q = queryBuilderService.buildQueryForSearch(qr, "entry");
    SearchResult result = service.executeQuery(q);
    assertEquals(73, result.getFound());
}
Also used : QueryRequest(org.nextprot.api.solr.QueryRequest) Query(org.nextprot.api.solr.Query) SearchResult(org.nextprot.api.solr.SearchResult) WebUnitBaseTest(org.nextprot.api.web.dbunit.base.mvc.WebUnitBaseTest) Test(org.junit.Test)

Example 18 with Query

use of org.nextprot.api.solr.Query in project nextprot-api by calipho-sib.

the class SolrServiceTest method shouldReturnResultsFromSimpleTermQuery.

@Test
public void shouldReturnResultsFromSimpleTermQuery() throws Exception {
    QueryRequest qr = new QueryRequest();
    qr.setQuery("liver");
    Query q = queryBuilderService.buildQueryForSearch(qr, "term");
    SearchResult result = service.executeQuery(q);
    assertEquals(1356, result.getFound());
}
Also used : QueryRequest(org.nextprot.api.solr.QueryRequest) Query(org.nextprot.api.solr.Query) SearchResult(org.nextprot.api.solr.SearchResult) WebUnitBaseTest(org.nextprot.api.web.dbunit.base.mvc.WebUnitBaseTest) Test(org.junit.Test)

Example 19 with Query

use of org.nextprot.api.solr.Query in project nextprot-api by calipho-sib.

the class SolrServiceTest method shouldReturnResultsFromSimpleEntryQuery.

@Test
public void shouldReturnResultsFromSimpleEntryQuery() throws Exception {
    QueryRequest qr = new QueryRequest();
    qr.setQuery("MSH6");
    Query q = queryBuilderService.buildQueryForSearch(qr, "entry");
    SearchResult result = service.executeQuery(q);
    assertEquals(101, result.getFound());
}
Also used : QueryRequest(org.nextprot.api.solr.QueryRequest) Query(org.nextprot.api.solr.Query) SearchResult(org.nextprot.api.solr.SearchResult) WebUnitBaseTest(org.nextprot.api.web.dbunit.base.mvc.WebUnitBaseTest) Test(org.junit.Test)

Example 20 with Query

use of org.nextprot.api.solr.Query in project nextprot-api by calipho-sib.

the class SearchServiceImpl method getAccessionsForSimple.

private Set<String> getAccessionsForSimple(QueryRequest queryRequest) {
    Set<String> set = new LinkedHashSet<>();
    try {
        Query query = this.queryBuilderService.buildQueryForSearchIndexes("entry", "simple", queryRequest);
        SearchResult results = solrService.executeIdQuery(query);
        for (Map<String, Object> f : results.getFoundFacets("id")) {
            String entry = (String) f.get("name");
            set.add(entry);
        }
    } catch (SearchQueryException e) {
        e.printStackTrace();
        throw new NextProtException("Error when retrieving accessions");
    }
    return set;
}
Also used : SearchQueryException(org.nextprot.api.commons.exception.SearchQueryException) NextProtException(org.nextprot.api.commons.exception.NextProtException) Query(org.nextprot.api.solr.Query) UserQuery(org.nextprot.api.user.domain.UserQuery) SearchResult(org.nextprot.api.solr.SearchResult)

Aggregations

Query (org.nextprot.api.solr.Query)20 SearchResult (org.nextprot.api.solr.SearchResult)20 QueryRequest (org.nextprot.api.solr.QueryRequest)16 Test (org.junit.Test)14 WebUnitBaseTest (org.nextprot.api.web.dbunit.base.mvc.WebUnitBaseTest)14 NextProtException (org.nextprot.api.commons.exception.NextProtException)4 SearchQueryException (org.nextprot.api.commons.exception.SearchQueryException)4 UserQuery (org.nextprot.api.user.domain.UserQuery)4 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 HashSet (java.util.HashSet)2 AutocompleteSearchResult (org.nextprot.api.solr.AutocompleteSearchResult)2 ApiMethod (org.jsondoc.core.annotation.ApiMethod)1 Ignore (org.junit.Ignore)1 UserProteinList (org.nextprot.api.user.domain.UserProteinList)1