Search in sources :

Example 1 with FieldDefRequest

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

the class TestIndexManager method registerFields.

protected static void registerFields(LuceneServerClient serverClient, String path) throws IOException {
    String registerFieldsJson = readResourceAsString(path);
    FieldDefRequest fieldDefRequest = getFieldDefRequest(registerFieldsJson);
    FieldDefResponse fieldDefResponse = serverClient.getBlockingStub().registerFields(fieldDefRequest);
    logger.info(fieldDefResponse.getResponse());
}
Also used : FieldDefRequest(com.yelp.nrtsearch.server.grpc.FieldDefRequest) FieldDefResponse(com.yelp.nrtsearch.server.grpc.FieldDefResponse)

Example 2 with FieldDefRequest

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

the class TestIndexManager method getFieldDefRequest.

private static FieldDefRequest getFieldDefRequest(String jsonStr) {
    logger.debug("Converting fields {} to proto FieldDefRequest", jsonStr);
    FieldDefRequest.Builder fieldDefRequestBuilder = FieldDefRequest.newBuilder();
    try {
        JsonFormat.parser().merge(jsonStr, fieldDefRequestBuilder);
    } catch (InvalidProtocolBufferException e) {
        throw new RuntimeException(e);
    }
    FieldDefRequest fieldDefRequest = fieldDefRequestBuilder.build();
    logger.debug("jsonStr converted to proto FieldDefRequest {}", fieldDefRequest);
    return fieldDefRequest;
}
Also used : StatusRuntimeException(io.grpc.StatusRuntimeException) FieldDefRequest(com.yelp.nrtsearch.server.grpc.FieldDefRequest) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException)

Example 3 with FieldDefRequest

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

the class YelpReviewsTest method getFieldDefRequest.

static FieldDefRequest getFieldDefRequest(String jsonStr) {
    logger.debug("Converting fields {} to proto FieldDefRequest", jsonStr);
    FieldDefRequest.Builder fieldDefRequestBuilder = FieldDefRequest.newBuilder();
    try {
        JsonFormat.parser().merge(jsonStr, fieldDefRequestBuilder);
    } catch (InvalidProtocolBufferException e) {
        throw new RuntimeException(e);
    }
    FieldDefRequest fieldDefRequest = fieldDefRequestBuilder.build();
    logger.debug("jsonStr converted to proto FieldDefRequest {}", fieldDefRequest);
    return fieldDefRequest;
}
Also used : StatusRuntimeException(io.grpc.StatusRuntimeException) FieldDefRequest(com.yelp.nrtsearch.server.grpc.FieldDefRequest) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException)

Example 4 with FieldDefRequest

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

the class YelpReviewsTest method registerFields.

private static void registerFields(LuceneServerClient serverClient) throws IOException {
    String registerFieldsJson = readResourceAsString("register_fields.json", ServerType.unknown);
    FieldDefRequest fieldDefRequest = getFieldDefRequest(registerFieldsJson);
    FieldDefResponse fieldDefResponse = serverClient.getBlockingStub().registerFields(fieldDefRequest);
    logger.info(fieldDefResponse.getResponse());
}
Also used : FieldDefRequest(com.yelp.nrtsearch.server.grpc.FieldDefRequest) FieldDefResponse(com.yelp.nrtsearch.server.grpc.FieldDefResponse)

Example 5 with FieldDefRequest

use of com.yelp.nrtsearch.server.grpc.FieldDefRequest 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)

Aggregations

FieldDefRequest (com.yelp.nrtsearch.server.grpc.FieldDefRequest)5 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)2 FieldDefResponse (com.yelp.nrtsearch.server.grpc.FieldDefResponse)2 StatusRuntimeException (io.grpc.StatusRuntimeException)2 AddDocumentRequest (com.yelp.nrtsearch.server.grpc.AddDocumentRequest)1 GrpcServer (com.yelp.nrtsearch.server.grpc.GrpcServer)1 LuceneServerGrpc (com.yelp.nrtsearch.server.grpc.LuceneServerGrpc)1