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());
}
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));
}
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));
}
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());
}
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());
}
Aggregations