use of org.opensearch.client.indices.AnalyzeRequest in project OpenSearch by opensearch-project.
the class RequestConverters method analyze.
static Request analyze(AnalyzeRequest request) throws IOException {
EndpointBuilder builder = new EndpointBuilder();
String index = request.index();
if (index != null) {
builder.addPathPart(index);
}
builder.addPathPartAsIs("_analyze");
Request req = new Request(HttpGet.METHOD_NAME, builder.build());
req.setEntity(createEntity(request, REQUEST_BODY_CONTENT_TYPE));
return req;
}
use of org.opensearch.client.indices.AnalyzeRequest in project OpenSearch by opensearch-project.
the class RequestConvertersTests method testAnalyzeRequest.
public void testAnalyzeRequest() throws Exception {
AnalyzeRequest indexAnalyzeRequest = AnalyzeRequest.withIndexAnalyzer("test_index", "test_analyzer", "Here is some text");
Request request = RequestConverters.analyze(indexAnalyzeRequest);
assertThat(request.getEndpoint(), equalTo("/test_index/_analyze"));
assertToXContentBody(indexAnalyzeRequest, request.getEntity());
AnalyzeRequest analyzeRequest = AnalyzeRequest.withGlobalAnalyzer("test_analyzer", "more text");
assertThat(RequestConverters.analyze(analyzeRequest).getEndpoint(), equalTo("/_analyze"));
}
use of org.opensearch.client.indices.AnalyzeRequest in project OpenSearch by opensearch-project.
the class IndicesClientIT method testAnalyze.
public void testAnalyze() throws Exception {
RestHighLevelClient client = highLevelClient();
AnalyzeRequest noindexRequest = AnalyzeRequest.withGlobalAnalyzer("english", "One two three");
AnalyzeResponse noindexResponse = execute(noindexRequest, client.indices()::analyze, client.indices()::analyzeAsync);
assertThat(noindexResponse.getTokens(), hasSize(3));
AnalyzeRequest detailsRequest = AnalyzeRequest.withGlobalAnalyzer("english", "One two three").explain(true);
AnalyzeResponse detailsResponse = execute(detailsRequest, client.indices()::analyze, client.indices()::analyzeAsync);
assertNotNull(detailsResponse.detail());
}
use of org.opensearch.client.indices.AnalyzeRequest in project OpenSearch by opensearch-project.
the class IndicesRequestConvertersTests method testAnalyzeRequest.
public void testAnalyzeRequest() throws Exception {
AnalyzeRequest indexAnalyzeRequest = AnalyzeRequest.withIndexAnalyzer("test_index", "test_analyzer", "Here is some text");
Request request = IndicesRequestConverters.analyze(indexAnalyzeRequest);
assertThat(request.getEndpoint(), equalTo("/test_index/_analyze"));
RequestConvertersTests.assertToXContentBody(indexAnalyzeRequest, request.getEntity());
AnalyzeRequest analyzeRequest = AnalyzeRequest.withGlobalAnalyzer("test_analyzer", "more text");
assertThat(IndicesRequestConverters.analyze(analyzeRequest).getEndpoint(), equalTo("/_analyze"));
}
use of org.opensearch.client.indices.AnalyzeRequest in project OpenSearch by opensearch-project.
the class IndicesRequestConverters method analyze.
static Request analyze(AnalyzeRequest request) throws IOException {
RequestConverters.EndpointBuilder builder = new RequestConverters.EndpointBuilder();
String index = request.index();
if (index != null) {
builder.addPathPart(index);
}
builder.addPathPartAsIs("_analyze");
Request req = new Request(HttpGet.METHOD_NAME, builder.build());
req.setEntity(RequestConverters.createEntity(request, RequestConverters.REQUEST_BODY_CONTENT_TYPE));
return req;
}
Aggregations