Search in sources :

Example 1 with GetIndexSettingsResponse

use of io.zulia.message.ZuliaServiceOuterClass.GetIndexSettingsResponse in project zuliasearch by zuliaio.

the class IndexController method get.

@Get
@Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
public HttpResponse<?> get(@QueryValue(ZuliaConstants.INDEX) String index, @QueryValue(value = ZuliaConstants.PRETTY, defaultValue = "true") Boolean pretty) {
    ZuliaIndexManager indexManager = ZuliaNodeProvider.getZuliaNode().getIndexManager();
    try {
        StringBuilder responseBuilder = new StringBuilder();
        GetIndexSettingsResponse getIndexSettingsResponse = indexManager.getIndexSettings(ZuliaServiceOuterClass.GetIndexSettingsRequest.newBuilder().setIndexName(index).build());
        responseBuilder.append("{");
        responseBuilder.append("\"indexSettings\": ");
        JsonFormat.Printer printer = JsonFormat.printer();
        responseBuilder.append(printer.print(getIndexSettingsResponse.getIndexSettings()));
        responseBuilder.append("}");
        String docString = responseBuilder.toString();
        if (pretty) {
            docString = JsonWriter.formatJson(docString);
        }
        return HttpResponse.ok(docString).status(ZuliaConstants.SUCCESS);
    } catch (Exception e) {
        return HttpResponse.serverError("Failed to get index names: " + e.getMessage()).status(ZuliaConstants.INTERNAL_ERROR);
    }
}
Also used : JsonFormat(com.google.protobuf.util.JsonFormat) GetIndexSettingsResponse(io.zulia.message.ZuliaServiceOuterClass.GetIndexSettingsResponse) ZuliaIndexManager(io.zulia.server.index.ZuliaIndexManager) Produces(io.micronaut.http.annotation.Produces) Get(io.micronaut.http.annotation.Get)

Example 2 with GetIndexSettingsResponse

use of io.zulia.message.ZuliaServiceOuterClass.GetIndexSettingsResponse in project zuliasearch by zuliaio.

the class GetIndexConfig method execute.

@Override
public GetIndexConfigResult execute(ZuliaConnection zuliaConnection) {
    ZuliaServiceBlockingStub service = zuliaConnection.getService();
    GetIndexSettingsResponse getIndexConfigResponse = service.getIndexSettings(getRequest());
    ClientIndexConfig indexConfig = new ClientIndexConfig();
    indexConfig.configure(getIndexConfigResponse.getIndexSettings());
    return new GetIndexConfigResult(indexConfig);
}
Also used : ZuliaServiceBlockingStub(io.zulia.message.ZuliaServiceGrpc.ZuliaServiceBlockingStub) GetIndexSettingsResponse(io.zulia.message.ZuliaServiceOuterClass.GetIndexSettingsResponse) GetIndexConfigResult(io.zulia.client.result.GetIndexConfigResult) ClientIndexConfig(io.zulia.client.config.ClientIndexConfig)

Aggregations

GetIndexSettingsResponse (io.zulia.message.ZuliaServiceOuterClass.GetIndexSettingsResponse)2 JsonFormat (com.google.protobuf.util.JsonFormat)1 Get (io.micronaut.http.annotation.Get)1 Produces (io.micronaut.http.annotation.Produces)1 ClientIndexConfig (io.zulia.client.config.ClientIndexConfig)1 GetIndexConfigResult (io.zulia.client.result.GetIndexConfigResult)1 ZuliaServiceBlockingStub (io.zulia.message.ZuliaServiceGrpc.ZuliaServiceBlockingStub)1 ZuliaIndexManager (io.zulia.server.index.ZuliaIndexManager)1