use of io.zulia.message.ZuliaServiceOuterClass.GetFieldNamesResponse in project zuliasearch by zuliaio.
the class FieldsController method get.
@Get
@Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
public HttpResponse<?> get(@QueryValue(ZuliaConstants.INDEX) final String indexName, @QueryValue(value = ZuliaConstants.PRETTY, defaultValue = "true") Boolean pretty) {
ZuliaIndexManager indexManager = ZuliaNodeProvider.getZuliaNode().getIndexManager();
GetFieldNamesRequest fieldNamesRequest = GetFieldNamesRequest.newBuilder().setIndexName(indexName).build();
GetFieldNamesResponse fieldNamesResponse;
try {
fieldNamesResponse = indexManager.getFieldNames(fieldNamesRequest);
Document mongoDocument = new Document();
mongoDocument.put("index", indexName);
mongoDocument.put("fields", fieldNamesResponse.getFieldNameList());
String docString = mongoDocument.toJson();
if (pretty) {
docString = JsonWriter.formatJson(docString);
}
return HttpResponse.ok(docString).status(ZuliaConstants.SUCCESS);
} catch (Exception e) {
return HttpResponse.ok("Failed to fetch fields for index <" + indexName + ">: " + e.getMessage()).status(ZuliaConstants.INTERNAL_ERROR);
}
}
use of io.zulia.message.ZuliaServiceOuterClass.GetFieldNamesResponse in project zuliasearch by zuliaio.
the class GetFieldNamesRequestFederator method getResponse.
public GetFieldNamesResponse getResponse(GetFieldNamesRequest request) throws Exception {
Set<String> fieldNames = new TreeSet<>();
List<GetFieldNamesResponse> responses = send(request);
for (GetFieldNamesResponse response : responses) {
fieldNames.addAll(response.getFieldNameList());
}
GetFieldNamesResponse.Builder responseBuilder = GetFieldNamesResponse.newBuilder();
responseBuilder.addAllFieldName(fieldNames);
return responseBuilder.build();
}
Aggregations