Skip to content

Commit

Permalink
Fix tokenizer serialization in AnalyzeRequest.toXContent() (#42795)
Browse files Browse the repository at this point in the history
Fixes #39670
  • Loading branch information
romseygeek committed Jun 4, 2019
1 parent 30150b4 commit 2f485b8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Expand Up @@ -1494,6 +1494,17 @@ public void testAnalyzeRequest() throws Exception {
assertThat(RequestConverters.analyze(analyzeRequest).getEndpoint(), equalTo("/_analyze"));
}

public void testAnalyzeRequestWithCustomAnalyzer() throws IOException {
AnalyzeRequest ar = new AnalyzeRequest()
.text("Here is some text")
.index("test_index")
.tokenizer("standard");

Request request = RequestConverters.analyze(ar);
assertThat(request.getEndpoint(), equalTo("/test_index/_analyze"));
assertToXContentBody(ar, request.getEntity());
}

public void testGetScriptRequest() {
GetStoredScriptRequest getStoredScriptRequest = new GetStoredScriptRequest("x-script");
Map<String, String> expectedParams = new HashMap<>();
Expand Down
Expand Up @@ -281,7 +281,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
builder.field("analyzer", analyzer);
}
if (tokenizer != null) {
tokenizer.toXContent(builder, params);
builder.field("tokenizer", tokenizer);
}
if (tokenFilters.size() > 0) {
builder.field("filter", tokenFilters);
Expand Down

0 comments on commit 2f485b8

Please sign in to comment.