Search in sources :

Example 6 with QueryRequest

use of org.nextprot.api.solr.QueryRequest 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);
}
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 7 with QueryRequest

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

the class SolrServiceTest method shoulReturnSomePublicationsWhenStopWordsAreIncludedInQuery.

@Test
public void shoulReturnSomePublicationsWhenStopWordsAreIncludedInQuery() throws Exception {
    QueryRequest qr;
    Query q;
    SearchResult result;
    long numFound;
    qr = new QueryRequest();
    qr.setQuery("polo like");
    q = queryBuilderService.buildQueryForSearch(qr, "publication");
    result = service.executeQuery(q);
    numFound = result.getFound();
    // we should get some results
    assertTrue(numFound > 0);
    qr = new QueryRequest();
    qr.setQuery("polo like in the of");
    q = queryBuilderService.buildQueryForSearch(qr, "publication");
    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 8 with QueryRequest

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

the class SolrServiceTest method shouldReturnResultsFromSimplePublicationQuery.

// indexes: gold-entry, entry, term, publication
@Test
public void shouldReturnResultsFromSimplePublicationQuery() throws Exception {
    QueryRequest qr = new QueryRequest();
    qr.setQuery("author:Doolittle");
    Query q = queryBuilderService.buildQueryForSearch(qr, "publication");
    SearchResult result = service.executeQuery(q);
    assertEquals(28, 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 9 with QueryRequest

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

the class SolrServiceTest method shouldReturnEmptyResultsFromEmptyQuery.

@Test
public void shouldReturnEmptyResultsFromEmptyQuery() throws Exception {
    QueryRequest qr = new QueryRequest();
    Query q = queryBuilderService.buildQueryForSearch(qr, "entry");
    SearchResult result = service.executeQuery(q);
    assertEquals(0, 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 10 with QueryRequest

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

the class SolrServiceTest method shouldReturnSomeResultsFromAccessionSet.

@Test
public void shouldReturnSomeResultsFromAccessionSet() throws Exception {
    Set<String> accessions = new HashSet<>(Arrays.asList("NX_P02671", "NX_P02675", "NX_P02679"));
    QueryRequest qr = new QueryRequest();
    qr.setQuality("GOLD");
    qr.setEntryAccessionSet(accessions);
    Query q = queryBuilderService.buildQueryForSearch(qr, "entry");
    SearchResult result = service.executeQuery(q);
    assertEquals(3, result.getFound());
    for (Map<String, Object> resultMap : result.getResults()) {
        assertTrue(accessions.contains(resultMap.get("id")));
    }
}
Also used : QueryRequest(org.nextprot.api.solr.QueryRequest) Query(org.nextprot.api.solr.Query) SearchResult(org.nextprot.api.solr.SearchResult) HashSet(java.util.HashSet) WebUnitBaseTest(org.nextprot.api.web.dbunit.base.mvc.WebUnitBaseTest) Test(org.junit.Test)

Aggregations

QueryRequest (org.nextprot.api.solr.QueryRequest)21 Test (org.junit.Test)16 Query (org.nextprot.api.solr.Query)16 SearchResult (org.nextprot.api.solr.SearchResult)16 WebUnitBaseTest (org.nextprot.api.web.dbunit.base.mvc.WebUnitBaseTest)14 NextProtException (org.nextprot.api.commons.exception.NextProtException)2 WebIntegrationBaseTest (org.nextprot.api.web.dbunit.base.mvc.WebIntegrationBaseTest)2 HashSet (java.util.HashSet)1 ApiMethod (org.jsondoc.core.annotation.ApiMethod)1 Ignore (org.junit.Ignore)1 SearchQueryException (org.nextprot.api.commons.exception.SearchQueryException)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1