Search in sources :

Example 1 with GrpcServer

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

the class ServerTestCase method setUpGrpcServer.

private GrpcServer setUpGrpcServer(CollectorRegistry collectorRegistry) throws IOException {
    String testIndex = "test_index";
    LuceneServerConfiguration luceneServerConfiguration = LuceneServerTestConfigurationFactory.getConfig(Mode.STANDALONE, folder.getRoot(), getExtraConfig());
    globalState = GlobalState.createState(luceneServerConfiguration);
    return new GrpcServer(collectorRegistry, grpcCleanup, luceneServerConfiguration, folder, false, globalState, luceneServerConfiguration.getIndexDir(), testIndex, globalState.getPort(), null, getPlugins());
}
Also used : LuceneServerConfiguration(com.yelp.nrtsearch.server.config.LuceneServerConfiguration) GrpcServer(com.yelp.nrtsearch.server.grpc.GrpcServer)

Example 2 with GrpcServer

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

the class ScoreScriptTest method testScriptDocValuesScoreQuery.

@Test
public void testScriptDocValuesScoreQuery() throws Exception {
    GrpcServer.TestServer testAddDocs = new GrpcServer.TestServer(grpcServer, true, Mode.STANDALONE);
    // 2 docs addDocuments
    testAddDocs.addDocuments();
    // manual refresh
    grpcServer.getBlockingStub().refresh(RefreshRequest.newBuilder().setIndexName(grpcServer.getTestIndex()).build());
    SearchResponse searchResponse = doFunctionScoreQuery("verify_doc_values");
    assertEquals(2, searchResponse.getHitsCount());
    assertEquals(1.5, searchResponse.getHits(0).getScore(), Math.ulp(1.5));
    assertEquals(1.5, searchResponse.getHits(1).getScore(), Math.ulp(1.5));
}
Also used : GrpcServer(com.yelp.nrtsearch.server.grpc.GrpcServer) SearchResponse(com.yelp.nrtsearch.server.grpc.SearchResponse) Test(org.junit.Test)

Example 3 with GrpcServer

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

the class ScoreScriptTest method testScriptUsingScoreInIndexField.

@Test
public void testScriptUsingScoreInIndexField() throws Exception {
    GrpcServer.TestServer testAddDocs = new GrpcServer.TestServer(grpcServer, false, Mode.STANDALONE);
    new GrpcServer.IndexAndRoleManager(grpcServer).createStartIndexAndRegisterFields(Mode.STANDALONE, 0, false, "registerFieldsScriptTest.json");
    AddDocumentResponse addDocumentResponse = testAddDocs.addDocuments("addDocs.csv");
    // manual refresh
    grpcServer.getBlockingStub().refresh(RefreshRequest.newBuilder().setIndexName(grpcServer.getTestIndex()).build());
    SearchResponse searchResponse = grpcServer.getBlockingStub().search(SearchRequest.newBuilder().setIndexName(grpcServer.getTestIndex()).addRetrieveFields("test_score").setStartHit(0).setTopHits(10).setQueryText("vendor_name:first vendor").build());
    assertEquals(2, searchResponse.getHitsCount());
    assertEquals(2.0, searchResponse.getHits(0).getFieldsOrThrow("test_score").getFieldValue(0).getDoubleValue(), Math.ulp(2.0));
    assertEquals(2.0, searchResponse.getHits(1).getFieldsOrThrow("test_score").getFieldValue(0).getDoubleValue(), Math.ulp(2.0));
}
Also used : GrpcServer(com.yelp.nrtsearch.server.grpc.GrpcServer) AddDocumentResponse(com.yelp.nrtsearch.server.grpc.AddDocumentResponse) SearchResponse(com.yelp.nrtsearch.server.grpc.SearchResponse) Test(org.junit.Test)

Example 4 with GrpcServer

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

the class NodeNameResolverAndLoadBalancingTests method startIndexAndAddDocuments.

private void startIndexAndAddDocuments(GrpcServer server, int id) throws InterruptedException, IOException {
    LuceneServerGrpc.LuceneServerBlockingStub stub = server.getBlockingStub();
    stub.createIndex(CreateIndexRequest.newBuilder().setIndexName(TEST_INDEX).build());
    FieldDefRequest fieldDefRequest = FieldDefRequest.newBuilder().setIndexName(TEST_INDEX).addField(Field.newBuilder().setName(FIELD_NAME).setType(FieldType.INT).setSearch(true).setStoreDocValues(true).build()).build();
    stub.registerFields(fieldDefRequest);
    stub.startIndex(StartIndexRequest.newBuilder().setIndexName(TEST_INDEX).build());
    AddDocumentRequest addDocumentRequest = AddDocumentRequest.newBuilder().setIndexName(TEST_INDEX).putFields(FIELD_NAME, AddDocumentRequest.MultiValuedField.newBuilder().addValue(String.valueOf(id)).build()).build();
    new GrpcServer.TestServer(server, false, Mode.STANDALONE).addDocumentsFromStream(Stream.of(addDocumentRequest));
    stub.commit(CommitRequest.newBuilder().setIndexName(TEST_INDEX).build());
    stub.refresh(RefreshRequest.newBuilder().setIndexName(TEST_INDEX).build());
}
Also used : LuceneServerGrpc(com.yelp.nrtsearch.server.grpc.LuceneServerGrpc) FieldDefRequest(com.yelp.nrtsearch.server.grpc.FieldDefRequest) GrpcServer(com.yelp.nrtsearch.server.grpc.GrpcServer) AddDocumentRequest(com.yelp.nrtsearch.server.grpc.AddDocumentRequest)

Example 5 with GrpcServer

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

the class NodeNameResolverAndLoadBalancingTests method createGrpcServer.

private GrpcServer createGrpcServer() throws IOException {
    LuceneServerConfiguration luceneServerConfiguration = LuceneServerTestConfigurationFactory.getConfig(Mode.STANDALONE, folder.getRoot());
    GlobalState globalState = GlobalState.createState(luceneServerConfiguration);
    return new GrpcServer(grpcCleanup, luceneServerConfiguration, folder, false, globalState, luceneServerConfiguration.getIndexDir(), TEST_INDEX, luceneServerConfiguration.getPort());
}
Also used : LuceneServerConfiguration(com.yelp.nrtsearch.server.config.LuceneServerConfiguration) GlobalState(com.yelp.nrtsearch.server.luceneserver.GlobalState) GrpcServer(com.yelp.nrtsearch.server.grpc.GrpcServer)

Aggregations

GrpcServer (com.yelp.nrtsearch.server.grpc.GrpcServer)11 SearchResponse (com.yelp.nrtsearch.server.grpc.SearchResponse)7 Test (org.junit.Test)6 LuceneServerConfiguration (com.yelp.nrtsearch.server.config.LuceneServerConfiguration)3 AddDocumentResponse (com.yelp.nrtsearch.server.grpc.AddDocumentResponse)3 VirtualField (com.yelp.nrtsearch.server.grpc.VirtualField)3 GlobalState (com.yelp.nrtsearch.server.luceneserver.GlobalState)2 AddDocumentRequest (com.yelp.nrtsearch.server.grpc.AddDocumentRequest)1 FieldDefRequest (com.yelp.nrtsearch.server.grpc.FieldDefRequest)1 LuceneServerGrpc (com.yelp.nrtsearch.server.grpc.LuceneServerGrpc)1