Search in sources :

Example 1 with TermQuery

use of com.yelp.nrtsearch.server.grpc.TermQuery in project nrtsearch by Yelp.

the class BooleanFieldTest method testTermQueryUnsetTerm.

@Test(expected = StatusRuntimeException.class)
public void testTermQueryUnsetTerm() {
    TermQuery falseQuery = TermQuery.newBuilder().setField("single").build();
    queryAndVerifyIds(falseQuery);
}
Also used : TermQuery(com.yelp.nrtsearch.server.grpc.TermQuery) Test(org.junit.Test)

Example 2 with TermQuery

use of com.yelp.nrtsearch.server.grpc.TermQuery in project nrtsearch by Yelp.

the class BooleanFieldTest method testTermQueryLongTerm.

@Test(expected = StatusRuntimeException.class)
public void testTermQueryLongTerm() {
    TermQuery falseQuery = TermQuery.newBuilder().setField("single").setLongValue(0).build();
    queryAndVerifyIds(falseQuery);
}
Also used : TermQuery(com.yelp.nrtsearch.server.grpc.TermQuery) Test(org.junit.Test)

Example 3 with TermQuery

use of com.yelp.nrtsearch.server.grpc.TermQuery in project nrtsearch by Yelp.

the class BooleanFieldTest method testTermQueryMultiOne.

@Test
public void testTermQueryMultiOne() {
    TermQuery falseBoolQuery = TermQuery.newBuilder().setField("multi_one").setBooleanValue(false).build();
    TermQuery trueBoolQuery = TermQuery.newBuilder().setField("multi_one").setBooleanValue(true).build();
    queryAndVerifyIds(trueBoolQuery, "2");
    queryAndVerifyIds(falseBoolQuery, "1");
}
Also used : TermQuery(com.yelp.nrtsearch.server.grpc.TermQuery) Test(org.junit.Test)

Example 4 with TermQuery

use of com.yelp.nrtsearch.server.grpc.TermQuery in project nrtsearch by Yelp.

the class BooleanFieldTest method queryAndVerifyIds.

private void queryAndVerifyIds(TermQuery termQuery, String... expectedIds) {
    Query query = Query.newBuilder().setTermQuery(termQuery).build();
    SearchResponse response = getGrpcServer().getBlockingStub().search(SearchRequest.newBuilder().setIndexName(DEFAULT_TEST_INDEX).setStartHit(0).setTopHits(10).setQuery(query).addRetrieveFields("doc_id").build());
    List<String> idList = Arrays.asList(expectedIds);
    assertEquals(idList.size(), response.getHitsCount());
    for (Hit hit : response.getHitsList()) {
        assertTrue(idList.contains(hit.getFieldsOrThrow("doc_id").getFieldValue(0).getTextValue()));
    }
}
Also used : Hit(com.yelp.nrtsearch.server.grpc.SearchResponse.Hit) TermQuery(com.yelp.nrtsearch.server.grpc.TermQuery) Query(com.yelp.nrtsearch.server.grpc.Query) TermInSetQuery(com.yelp.nrtsearch.server.grpc.TermInSetQuery) SearchResponse(com.yelp.nrtsearch.server.grpc.SearchResponse)

Example 5 with TermQuery

use of com.yelp.nrtsearch.server.grpc.TermQuery in project nrtsearch by Yelp.

the class BooleanFieldTest method testTermQueryMultiOneBooleanStrings.

public void testTermQueryMultiOneBooleanStrings() {
    TermQuery falseQuery = TermQuery.newBuilder().setField("multi_one").setTextValue("false").build();
    TermQuery trueQuery = TermQuery.newBuilder().setField("multi_one").setTextValue("true").build();
    queryAndVerifyIds(trueQuery, "2");
    queryAndVerifyIds(falseQuery, "1");
}
Also used : TermQuery(com.yelp.nrtsearch.server.grpc.TermQuery)

Aggregations

TermQuery (com.yelp.nrtsearch.server.grpc.TermQuery)25 Test (org.junit.Test)18 Query (com.yelp.nrtsearch.server.grpc.Query)2 SearchResponse (com.yelp.nrtsearch.server.grpc.SearchResponse)2 Hit (com.yelp.nrtsearch.server.grpc.SearchResponse.Hit)2 TermInSetQuery (com.yelp.nrtsearch.server.grpc.TermInSetQuery)2