Search in sources :

Example 6 with SearchResult

use of org.nextprot.api.solr.SearchResult 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 7 with SearchResult

use of org.nextprot.api.solr.SearchResult 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 8 with SearchResult

use of org.nextprot.api.solr.SearchResult 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 9 with SearchResult

use of org.nextprot.api.solr.SearchResult 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)

Example 10 with SearchResult

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

the class SolrServiceTest method shouldReturnEmptyResultsFromEmptyAccessionSet.

@Test
public void shouldReturnEmptyResultsFromEmptyAccessionSet() throws Exception {
    QueryRequest qr = new QueryRequest();
    qr.setQuality("GOLD");
    qr.setEntryAccessionSet(new HashSet<>());
    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)

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