From 370f0b885e347c7659f60e78865ca40350b46ced Mon Sep 17 00:00:00 2001 From: Jun Ohtani Date: Thu, 22 Sep 2016 20:54:30 +0900 Subject: [PATCH 1/4] Removing request parameters in _analyze API Remove request params in _analyze API without index param Change rest-api-test using JSON Change docs using JSON Closes #20246 --- .../admin/indices/RestAnalyzeAction.java | 32 +---------- .../admin/indices/RestAnalyzeActionTests.java | 12 ++++- docs/plugins/analysis-icu.asciidoc | 15 ++++-- docs/plugins/analysis-kuromoji.asciidoc | 54 +++++++++++++++---- docs/plugins/analysis-phonetic.asciidoc | 6 ++- docs/reference/indices/analyze.asciidoc | 15 ------ .../mapping/params/analyzer.asciidoc | 6 ++- .../test/analysis_icu/10_basic.yaml | 26 +++++---- .../test/analysis_kuromoji/10_basic.yaml | 31 ++++++----- .../test/analysis_phonetic/10_metaphone.yaml | 5 +- .../20_double_metaphone.yaml | 5 +- .../analysis_phonetic/30_beider_morse.yaml | 5 +- .../analysis_phonetic/50_daitch_mokotoff.yaml | 5 +- .../test/analysis_smartcn/10_basic.yaml | 10 ++-- .../test/analysis_stempel/10_basic.yaml | 12 +++-- .../test/indices.analyze/10_analyze.yaml | 23 ++++---- 16 files changed, 144 insertions(+), 118 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/RestAnalyzeAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/RestAnalyzeAction.java index 247df1a380e..02ac7201fb3 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/RestAnalyzeAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/RestAnalyzeAction.java @@ -67,42 +67,14 @@ public class RestAnalyzeAction extends BaseRestHandler { @Override public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException { - String[] texts = request.paramAsStringArrayOrEmptyIfAll("text"); - AnalyzeRequest analyzeRequest = new AnalyzeRequest(request.param("index")); - analyzeRequest.text(texts); - analyzeRequest.analyzer(request.param("analyzer")); - analyzeRequest.field(request.param("field")); - final String tokenizer = request.param("tokenizer"); - if (tokenizer != null) { - analyzeRequest.tokenizer(tokenizer); - } - for (String filter : request.paramAsStringArray("filter", Strings.EMPTY_ARRAY)) { - analyzeRequest.addTokenFilter(filter); - } - for (String charFilter : request.paramAsStringArray("char_filter", Strings.EMPTY_ARRAY)) { - analyzeRequest.addTokenFilter(charFilter); - } - analyzeRequest.explain(request.paramAsBoolean("explain", false)); - analyzeRequest.attributes(request.paramAsStringArray("attributes", analyzeRequest.attributes())); - if (RestActions.hasBodyContent(request)) { - XContentType type = RestActions.guessBodyContentType(request); - if (type == null) { - if (texts == null || texts.length == 0) { - texts = new String[]{ RestActions.getRestContent(request).utf8ToString() }; - analyzeRequest.text(texts); - } - } else { - // NOTE: if rest request with xcontent body has request parameters, the parameters does not override xcontent values - buildFromContent(RestActions.getRestContent(request), analyzeRequest, parseFieldMatcher); - } - } + buildFromContent(RestActions.getRestContent(request), analyzeRequest, parseFieldMatcher); return channel -> client.admin().indices().analyze(analyzeRequest, new RestToXContentListener<>(channel)); } - public static void buildFromContent(BytesReference content, AnalyzeRequest analyzeRequest, ParseFieldMatcher parseFieldMatcher) { + static void buildFromContent(BytesReference content, AnalyzeRequest analyzeRequest, ParseFieldMatcher parseFieldMatcher) { try (XContentParser parser = XContentHelper.createParser(content)) { if (parser.nextToken() != XContentParser.Token.START_OBJECT) { throw new IllegalArgumentException("Malformed content, must start with an object"); diff --git a/core/src/test/java/org/elasticsearch/rest/action/admin/indices/RestAnalyzeActionTests.java b/core/src/test/java/org/elasticsearch/rest/action/admin/indices/RestAnalyzeActionTests.java index 9b7d4073d0d..980a76d12cb 100644 --- a/core/src/test/java/org/elasticsearch/rest/action/admin/indices/RestAnalyzeActionTests.java +++ b/core/src/test/java/org/elasticsearch/rest/action/admin/indices/RestAnalyzeActionTests.java @@ -19,16 +19,25 @@ package org.elasticsearch.rest.action.admin.indices; import org.elasticsearch.action.admin.indices.analyze.AnalyzeRequest; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.ParseFieldMatcher; import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentFactory; +import org.elasticsearch.rest.RestChannel; +import org.elasticsearch.rest.RestRequest; import org.elasticsearch.test.ESTestCase; +import org.elasticsearch.test.rest.FakeRestRequest; + +import java.util.HashMap; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.notNullValue; import static org.hamcrest.Matchers.startsWith; +import static org.mockito.Mockito.doCallRealMethod; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; public class RestAnalyzeActionTests extends ESTestCase { @@ -118,7 +127,7 @@ public class RestAnalyzeActionTests extends ESTestCase { assertThat(e.getMessage(), startsWith("explain must be either 'true' or 'false'")); } - public void testDeprecatedParamException() throws Exception { + public void testDeprecatedParamIn2xException() throws Exception { IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> RestAnalyzeAction.buildFromContent( XContentFactory.jsonBuilder() @@ -165,5 +174,4 @@ public class RestAnalyzeActionTests extends ESTestCase { , new AnalyzeRequest("for test"), new ParseFieldMatcher(Settings.EMPTY))); assertThat(e.getMessage(), startsWith("Unknown parameter [token_filter]")); } - } diff --git a/docs/plugins/analysis-icu.asciidoc b/docs/plugins/analysis-icu.asciidoc index 1677634bb56..5ea55d7437d 100644 --- a/docs/plugins/analysis-icu.asciidoc +++ b/docs/plugins/analysis-icu.asciidoc @@ -164,7 +164,11 @@ PUT icu_sample } } -POST icu_sample/_analyze?analyzer=my_analyzer&text=Elasticsearch. Wow! +POST icu_sample/_analyze +{ + "analyzer": "my_analyzer", + "text": "Elasticsearch. Wow!" +} -------------------------------------------------- // CONSOLE @@ -480,18 +484,21 @@ PUT icu_sample } } -GET icu_sample/_analyze?analyzer=latin +GET icu_sample/_analyze { + "analyzer": "latin", "text": "你好" <2> } -GET icu_sample/_analyze?analyzer=latin +GET icu_sample/_analyze { + "analyzer": "latin", "text": "здравствуйте" <3> } -GET icu_sample/_analyze?analyzer=latin +GET icu_sample/_analyze { + "analyzer": "latin", "text": "こんにちは" <4> } diff --git a/docs/plugins/analysis-kuromoji.asciidoc b/docs/plugins/analysis-kuromoji.asciidoc index 6b3dc0a72f1..44eab2f2329 100644 --- a/docs/plugins/analysis-kuromoji.asciidoc +++ b/docs/plugins/analysis-kuromoji.asciidoc @@ -175,7 +175,11 @@ PUT kuromoji_sample } } -POST kuromoji_sample/_analyze?analyzer=my_analyzer&text=東京スカイツリー +POST kuromoji_sample/_analyze +{ + "analyzer": "my_analyzer", + "text": "東京スカイツリー" +} -------------------------------------------------- // CONSOLE @@ -228,7 +232,11 @@ PUT kuromoji_sample } } -POST kuromoji_sample/_analyze?analyzer=my_analyzer&text=飲み +POST kuromoji_sample/_analyze +{ + "analyzer": "my_analyzer", + "text": "飲み" +} -------------------------------------------------- // CONSOLE @@ -290,7 +298,11 @@ PUT kuromoji_sample } } -POST kuromoji_sample/_analyze?analyzer=my_analyzer&text=寿司がおいしいね +POST kuromoji_sample/_analyze +{ + "analyzer": "my_analyzer", + "text": "寿司がおいしいね" +} -------------------------------------------------- // CONSOLE @@ -363,9 +375,17 @@ PUT kuromoji_sample } } -POST kuromoji_sample/_analyze?analyzer=katakana_analyzer&text=寿司 <1> +POST kuromoji_sample/_analyze +{ + "analyzer": "katakana_analyzer", + "text": "寿司" <1> +} -POST kuromoji_sample/_analyze?analyzer=romaji_analyzer&text=寿司 <2> +POST kuromoji_sample/_analyze +{ + "analyzer": "romaji_analyzer", + "text": "寿司" <2> +} -------------------------------------------------- // CONSOLE @@ -413,9 +433,17 @@ PUT kuromoji_sample } } -POST kuromoji_sample/_analyze?analyzer=my_analyzer&text=コピー <1> +POST kuromoji_sample/_analyze +{ + "analyzer": "my_analyzer", + "text": "コピー" <1> +} -POST kuromoji_sample/_analyze?analyzer=my_analyzer&text=サーバー <2> +POST kuromoji_sample/_analyze +{ + "analyzer": "my_analyzer", + "text": "サーバー" <2> +} -------------------------------------------------- // CONSOLE @@ -461,7 +489,11 @@ PUT kuromoji_sample } } -POST kuromoji_sample/_analyze?analyzer=analyzer_with_ja_stop&text=ストップは消える +POST kuromoji_sample/_analyze +{ + "analyzer": "analyzer_with_ja_stop", + "text": "ストップは消える" +} -------------------------------------------------- // CONSOLE @@ -507,7 +539,11 @@ PUT kuromoji_sample } } -POST kuromoji_sample/_analyze?analyzer=my_analyzer&text=一〇〇〇 +POST kuromoji_sample/_analyze +{ + "analyzer": "my_analyzer", + "text": "一〇〇〇" +} -------------------------------------------------- // CONSOLE diff --git a/docs/plugins/analysis-phonetic.asciidoc b/docs/plugins/analysis-phonetic.asciidoc index 0544900a8ca..fffbfcbd103 100644 --- a/docs/plugins/analysis-phonetic.asciidoc +++ b/docs/plugins/analysis-phonetic.asciidoc @@ -82,7 +82,11 @@ PUT phonetic_sample } } -POST phonetic_sample/_analyze?analyzer=my_analyzer&text=Joe Bloggs <1> +POST phonetic_sample/_analyze +{ + "analyzer": "my_analyzer", + "text": "Joe Bloggs" <1> +} -------------------------------------------------- // CONSOLE diff --git a/docs/reference/indices/analyze.asciidoc b/docs/reference/indices/analyze.asciidoc index dbb2c8f101a..0d9d60d4845 100644 --- a/docs/reference/indices/analyze.asciidoc +++ b/docs/reference/indices/analyze.asciidoc @@ -100,21 +100,6 @@ curl -XGET 'localhost:9200/test/_analyze' -d ' Will cause the analysis to happen based on the analyzer configured in the mapping for `obj1.field1` (and if not, the default index analyzer). -All parameters can also supplied as request parameters. For example: - -[source,js] --------------------------------------------------- -curl -XGET 'localhost:9200/_analyze?tokenizer=keyword&filter=lowercase&text=this+is+a+test' --------------------------------------------------- - -For backwards compatibility, we also accept the text parameter as the body of the request, -provided it doesn't start with `{` : - -[source,js] --------------------------------------------------- -curl -XGET 'localhost:9200/_analyze?tokenizer=keyword&filter=lowercase&char_filter=html_strip' -d 'this is a test' --------------------------------------------------- - === Explain Analyze If you want to get more advanced details, set `explain` to `true` (defaults to `false`). It will output all token attributes for each token. diff --git a/docs/reference/mapping/params/analyzer.asciidoc b/docs/reference/mapping/params/analyzer.asciidoc index c075b662805..0b60451e02a 100644 --- a/docs/reference/mapping/params/analyzer.asciidoc +++ b/docs/reference/mapping/params/analyzer.asciidoc @@ -60,13 +60,15 @@ PUT /my_index } } -GET my_index/_analyze?field=text <3> +GET my_index/_analyze <3> { + "field": "text", "text": "The quick Brown Foxes." } -GET my_index/_analyze?field=text.english <4> +GET my_index/_analyze <4> { + "field": "text.english", "text": "The quick Brown Foxes." } -------------------------------------------------- diff --git a/plugins/analysis-icu/src/test/resources/rest-api-spec/test/analysis_icu/10_basic.yaml b/plugins/analysis-icu/src/test/resources/rest-api-spec/test/analysis_icu/10_basic.yaml index 64fbbcadf7d..180f6c6f5b6 100644 --- a/plugins/analysis-icu/src/test/resources/rest-api-spec/test/analysis_icu/10_basic.yaml +++ b/plugins/analysis-icu/src/test/resources/rest-api-spec/test/analysis_icu/10_basic.yaml @@ -3,8 +3,9 @@ "Tokenizer": - do: indices.analyze: - text: Foo Bar - tokenizer: icu_tokenizer + body: + text: Foo Bar + tokenizer: icu_tokenizer - length: { tokens: 2 } - match: { tokens.0.token: Foo } - match: { tokens.1.token: Bar } @@ -12,26 +13,29 @@ "Normalization filter": - do: indices.analyze: - filter: icu_normalizer - text: Foo Bar Ruß - tokenizer: keyword + body: + filter: [icu_normalizer] + text: Foo Bar Ruß + tokenizer: keyword - length: { tokens: 1 } - match: { tokens.0.token: foo bar russ } --- "Normalization charfilter": - do: indices.analyze: - char_filter: icu_normalizer - text: Foo Bar Ruß - tokenizer: keyword + body: + char_filter: [icu_normalizer] + text: Foo Bar Ruß + tokenizer: keyword - length: { tokens: 1 } - match: { tokens.0.token: foo bar russ } --- "Folding filter": - do: indices.analyze: - filter: icu_folding - text: Foo Bar résumé - tokenizer: keyword + body: + filter: [icu_folding] + text: Foo Bar résumé + tokenizer: keyword - length: { tokens: 1 } - match: { tokens.0.token: foo bar resume } diff --git a/plugins/analysis-kuromoji/src/test/resources/rest-api-spec/test/analysis_kuromoji/10_basic.yaml b/plugins/analysis-kuromoji/src/test/resources/rest-api-spec/test/analysis_kuromoji/10_basic.yaml index 42df558567d..1cca2b728e0 100644 --- a/plugins/analysis-kuromoji/src/test/resources/rest-api-spec/test/analysis_kuromoji/10_basic.yaml +++ b/plugins/analysis-kuromoji/src/test/resources/rest-api-spec/test/analysis_kuromoji/10_basic.yaml @@ -4,8 +4,9 @@ "Analyzer": - do: indices.analyze: - text: JR新宿駅の近くにビールを飲みに行こうか - analyzer: kuromoji + body: + text: JR新宿駅の近くにビールを飲みに行こうか + analyzer: kuromoji - length: { tokens: 7 } - match: { tokens.0.token: jr } - match: { tokens.1.token: 新宿 } @@ -18,8 +19,9 @@ "Tokenizer": - do: indices.analyze: - text: 関西国際空港 - tokenizer: kuromoji_tokenizer + body: + text: 関西国際空港 + tokenizer: kuromoji_tokenizer - length: { tokens: 4 } - match: { tokens.0.token: 関西 } - match: { tokens.1.token: 関西国際空港 } @@ -29,26 +31,29 @@ "Baseform filter": - do: indices.analyze: - text: 飲み - tokenizer: kuromoji_tokenizer - filter: kuromoji_baseform + body: + text: 飲み + tokenizer: kuromoji_tokenizer + filter: [kuromoji_baseform] - length: { tokens: 1 } - match: { tokens.0.token: 飲む } --- "Reading filter": - do: indices.analyze: - text: 寿司 - tokenizer: kuromoji_tokenizer - filter: kuromoji_readingform + body: + text: 寿司 + tokenizer: kuromoji_tokenizer + filter: [kuromoji_readingform] - length: { tokens: 1 } - match: { tokens.0.token: スシ } --- "Stemming filter": - do: indices.analyze: - text: サーバー - tokenizer: kuromoji_tokenizer - filter: kuromoji_stemmer + body: + text: サーバー + tokenizer: kuromoji_tokenizer + filter: [kuromoji_stemmer] - length: { tokens: 1 } - match: { tokens.0.token: サーバ } diff --git a/plugins/analysis-phonetic/src/test/resources/rest-api-spec/test/analysis_phonetic/10_metaphone.yaml b/plugins/analysis-phonetic/src/test/resources/rest-api-spec/test/analysis_phonetic/10_metaphone.yaml index 02d4b315b6e..1f326fe3776 100644 --- a/plugins/analysis-phonetic/src/test/resources/rest-api-spec/test/analysis_phonetic/10_metaphone.yaml +++ b/plugins/analysis-phonetic/src/test/resources/rest-api-spec/test/analysis_phonetic/10_metaphone.yaml @@ -22,8 +22,9 @@ - do: indices.analyze: index: phonetic_sample - analyzer: my_analyzer - text: Joe Bloggs + body: + analyzer: my_analyzer + text: Joe Bloggs - length: { tokens: 4 } - match: { tokens.0.token: J } diff --git a/plugins/analysis-phonetic/src/test/resources/rest-api-spec/test/analysis_phonetic/20_double_metaphone.yaml b/plugins/analysis-phonetic/src/test/resources/rest-api-spec/test/analysis_phonetic/20_double_metaphone.yaml index 675847e557e..5af9f48aa80 100644 --- a/plugins/analysis-phonetic/src/test/resources/rest-api-spec/test/analysis_phonetic/20_double_metaphone.yaml +++ b/plugins/analysis-phonetic/src/test/resources/rest-api-spec/test/analysis_phonetic/20_double_metaphone.yaml @@ -22,8 +22,9 @@ - do: indices.analyze: index: phonetic_sample - analyzer: my_analyzer - text: supercalifragilisticexpialidocious + body: + analyzer: my_analyzer + text: supercalifragilisticexpialidocious - length: { tokens: 1 } - match: { tokens.0.token: SPRKLF } diff --git a/plugins/analysis-phonetic/src/test/resources/rest-api-spec/test/analysis_phonetic/30_beider_morse.yaml b/plugins/analysis-phonetic/src/test/resources/rest-api-spec/test/analysis_phonetic/30_beider_morse.yaml index 015610af172..259b0adea74 100644 --- a/plugins/analysis-phonetic/src/test/resources/rest-api-spec/test/analysis_phonetic/30_beider_morse.yaml +++ b/plugins/analysis-phonetic/src/test/resources/rest-api-spec/test/analysis_phonetic/30_beider_morse.yaml @@ -24,8 +24,9 @@ - do: indices.analyze: index: phonetic_sample - analyzer: my_analyzer - text: Szwarc + body: + analyzer: my_analyzer + text: Szwarc - length: { tokens: 1 } - match: { tokens.0.token: Svarts } diff --git a/plugins/analysis-phonetic/src/test/resources/rest-api-spec/test/analysis_phonetic/50_daitch_mokotoff.yaml b/plugins/analysis-phonetic/src/test/resources/rest-api-spec/test/analysis_phonetic/50_daitch_mokotoff.yaml index 5125ae3d684..c67b6892bc9 100644 --- a/plugins/analysis-phonetic/src/test/resources/rest-api-spec/test/analysis_phonetic/50_daitch_mokotoff.yaml +++ b/plugins/analysis-phonetic/src/test/resources/rest-api-spec/test/analysis_phonetic/50_daitch_mokotoff.yaml @@ -21,8 +21,9 @@ - do: indices.analyze: index: phonetic_sample - analyzer: my_analyzer - text: Moskowitz + body: + analyzer: my_analyzer + text: Moskowitz - length: { tokens: 1 } - match: { tokens.0.token: "645740" } diff --git a/plugins/analysis-smartcn/src/test/resources/rest-api-spec/test/analysis_smartcn/10_basic.yaml b/plugins/analysis-smartcn/src/test/resources/rest-api-spec/test/analysis_smartcn/10_basic.yaml index 2549f774f81..0f1b2805c93 100644 --- a/plugins/analysis-smartcn/src/test/resources/rest-api-spec/test/analysis_smartcn/10_basic.yaml +++ b/plugins/analysis-smartcn/src/test/resources/rest-api-spec/test/analysis_smartcn/10_basic.yaml @@ -3,8 +3,9 @@ "Tokenizer": - do: indices.analyze: - text: 我购买了道具和服装。 - tokenizer: smartcn_tokenizer + body: + text: 我购买了道具和服装。 + tokenizer: smartcn_tokenizer - length: { tokens: 7 } - match: { tokens.0.token: 我 } - match: { tokens.1.token: 购买 } @@ -17,8 +18,9 @@ "Analyzer": - do: indices.analyze: - text: 我购买了道具和服装。 - analyzer: smartcn + body: + text: 我购买了道具和服装。 + analyzer: smartcn - length: { tokens: 6 } - match: { tokens.0.token: 我 } - match: { tokens.1.token: 购买 } diff --git a/plugins/analysis-stempel/src/test/resources/rest-api-spec/test/analysis_stempel/10_basic.yaml b/plugins/analysis-stempel/src/test/resources/rest-api-spec/test/analysis_stempel/10_basic.yaml index f87f00b7922..1941126c64f 100644 --- a/plugins/analysis-stempel/src/test/resources/rest-api-spec/test/analysis_stempel/10_basic.yaml +++ b/plugins/analysis-stempel/src/test/resources/rest-api-spec/test/analysis_stempel/10_basic.yaml @@ -3,16 +3,18 @@ "Stemmer": - do: indices.analyze: - text: studenci - tokenizer: keyword - filter: polish_stem + body: + text: studenci + tokenizer: keyword + filter: [polish_stem] - length: { tokens: 1 } - match: { tokens.0.token: student } --- "Analyzer": - do: indices.analyze: - text: studenta był - analyzer: polish + body: + text: studenta był + analyzer: polish - length: { tokens: 1 } - match: { tokens.0.token: student } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.analyze/10_analyze.yaml b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.analyze/10_analyze.yaml index 35d4a2b5222..268cd781289 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.analyze/10_analyze.yaml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.analyze/10_analyze.yaml @@ -8,7 +8,8 @@ setup: "Basic test": - do: indices.analyze: - text: Foo Bar + body: + text: Foo Bar - length: { tokens: 2 } - match: { tokens.0.token: foo } - match: { tokens.1.token: bar } @@ -17,9 +18,10 @@ setup: "Tokenizer and filter": - do: indices.analyze: - filter: lowercase - text: Foo Bar - tokenizer: keyword + body: + filter: [lowercase] + text: Foo Bar + tokenizer: keyword - length: { tokens: 1 } - match: { tokens.0.token: foo bar } @@ -38,9 +40,10 @@ setup: - do: indices.analyze: - field: text index: test - text: Foo Bar! + body: + field: text + text: Foo Bar! - length: { tokens: 2 } - match: { tokens.0.token: Foo } - match: { tokens.1.token: Bar! } @@ -52,14 +55,6 @@ setup: - length: {tokens: 1 } - match: { tokens.0.token: foo bar } --- -"Body params override query string": - - do: - indices.analyze: - text: Foo Bar - body: { "text": "Bar Foo", "filter": ["lowercase"], "tokenizer": keyword } - - length: {tokens: 1 } - - match: { tokens.0.token: bar foo } ---- "Array text": - do: indices.analyze: From eca9894c5f27e6189f5974f6215e26833dfdd65e Mon Sep 17 00:00:00 2001 From: Jun Ohtani Date: Sat, 1 Oct 2016 05:42:45 +0900 Subject: [PATCH 2/4] Removing request parameters in _analyze API Remove unused imports Replace POST method by GET method in docs Add breaking changes explanation Fix small issue in Kuromoji docs Closes #20246 --- .../admin/indices/RestAnalyzeAction.java | 2 -- .../admin/indices/RestAnalyzeActionTests.java | 9 -------- docs/plugins/analysis-icu.asciidoc | 2 +- docs/plugins/analysis-kuromoji.asciidoc | 22 +++++++++---------- docs/plugins/analysis-phonetic.asciidoc | 2 +- .../migration/migrate_6_0/rest.asciidoc | 4 ++++ 6 files changed, 17 insertions(+), 24 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/RestAnalyzeAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/RestAnalyzeAction.java index 02ac7201fb3..1390e9d771d 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/RestAnalyzeAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/RestAnalyzeAction.java @@ -22,13 +22,11 @@ import org.elasticsearch.action.admin.indices.analyze.AnalyzeRequest; import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.ParseFieldMatcher; -import org.elasticsearch.common.Strings; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentHelper; import org.elasticsearch.common.xcontent.XContentParser; -import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.rest.BaseRestHandler; import org.elasticsearch.rest.RestController; import org.elasticsearch.rest.RestRequest; diff --git a/core/src/test/java/org/elasticsearch/rest/action/admin/indices/RestAnalyzeActionTests.java b/core/src/test/java/org/elasticsearch/rest/action/admin/indices/RestAnalyzeActionTests.java index 980a76d12cb..385bfd17b1d 100644 --- a/core/src/test/java/org/elasticsearch/rest/action/admin/indices/RestAnalyzeActionTests.java +++ b/core/src/test/java/org/elasticsearch/rest/action/admin/indices/RestAnalyzeActionTests.java @@ -19,25 +19,16 @@ package org.elasticsearch.rest.action.admin.indices; import org.elasticsearch.action.admin.indices.analyze.AnalyzeRequest; -import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.ParseFieldMatcher; import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentFactory; -import org.elasticsearch.rest.RestChannel; -import org.elasticsearch.rest.RestRequest; import org.elasticsearch.test.ESTestCase; -import org.elasticsearch.test.rest.FakeRestRequest; - -import java.util.HashMap; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.notNullValue; import static org.hamcrest.Matchers.startsWith; -import static org.mockito.Mockito.doCallRealMethod; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; public class RestAnalyzeActionTests extends ESTestCase { diff --git a/docs/plugins/analysis-icu.asciidoc b/docs/plugins/analysis-icu.asciidoc index 5ea55d7437d..7ba57f9df4f 100644 --- a/docs/plugins/analysis-icu.asciidoc +++ b/docs/plugins/analysis-icu.asciidoc @@ -164,7 +164,7 @@ PUT icu_sample } } -POST icu_sample/_analyze +GET icu_sample/_analyze { "analyzer": "my_analyzer", "text": "Elasticsearch. Wow!" diff --git a/docs/plugins/analysis-kuromoji.asciidoc b/docs/plugins/analysis-kuromoji.asciidoc index 44eab2f2329..80823938fa8 100644 --- a/docs/plugins/analysis-kuromoji.asciidoc +++ b/docs/plugins/analysis-kuromoji.asciidoc @@ -175,7 +175,7 @@ PUT kuromoji_sample } } -POST kuromoji_sample/_analyze +GET kuromoji_sample/_analyze { "analyzer": "my_analyzer", "text": "東京スカイツリー" @@ -232,7 +232,7 @@ PUT kuromoji_sample } } -POST kuromoji_sample/_analyze +GET kuromoji_sample/_analyze { "analyzer": "my_analyzer", "text": "飲み" @@ -298,7 +298,7 @@ PUT kuromoji_sample } } -POST kuromoji_sample/_analyze +GET kuromoji_sample/_analyze { "analyzer": "my_analyzer", "text": "寿司がおいしいね" @@ -375,13 +375,13 @@ PUT kuromoji_sample } } -POST kuromoji_sample/_analyze +GET kuromoji_sample/_analyze { "analyzer": "katakana_analyzer", "text": "寿司" <1> } -POST kuromoji_sample/_analyze +GET kuromoji_sample/_analyze { "analyzer": "romaji_analyzer", "text": "寿司" <2> @@ -433,13 +433,13 @@ PUT kuromoji_sample } } -POST kuromoji_sample/_analyze +GET kuromoji_sample/_analyze { "analyzer": "my_analyzer", "text": "コピー" <1> } -POST kuromoji_sample/_analyze +GET kuromoji_sample/_analyze { "analyzer": "my_analyzer", "text": "サーバー" <2> @@ -452,7 +452,7 @@ POST kuromoji_sample/_analyze [[analysis-kuromoji-stop]] -===== `ja_stop` token filter +==== `ja_stop` token filter The `ja_stop` token filter filters out Japanese stopwords (`_japanese_`), and any other custom stopwords specified by the user. This filter only supports @@ -489,7 +489,7 @@ PUT kuromoji_sample } } -POST kuromoji_sample/_analyze +GET kuromoji_sample/_analyze { "analyzer": "analyzer_with_ja_stop", "text": "ストップは消える" @@ -514,7 +514,7 @@ The above request returns: // TESTRESPONSE [[analysis-kuromoji-number]] -===== `kuromoji_number` token filter +==== `kuromoji_number` token filter The `kuromoji_number` token filter normalizes Japanese numbers (kansūji) to regular Arabic decimal numbers in half-width characters. For example: @@ -539,7 +539,7 @@ PUT kuromoji_sample } } -POST kuromoji_sample/_analyze +GET kuromoji_sample/_analyze { "analyzer": "my_analyzer", "text": "一〇〇〇" diff --git a/docs/plugins/analysis-phonetic.asciidoc b/docs/plugins/analysis-phonetic.asciidoc index fffbfcbd103..7f50679a9a1 100644 --- a/docs/plugins/analysis-phonetic.asciidoc +++ b/docs/plugins/analysis-phonetic.asciidoc @@ -82,7 +82,7 @@ PUT phonetic_sample } } -POST phonetic_sample/_analyze +GET phonetic_sample/_analyze { "analyzer": "my_analyzer", "text": "Joe Bloggs" <1> diff --git a/docs/reference/migration/migrate_6_0/rest.asciidoc b/docs/reference/migration/migrate_6_0/rest.asciidoc index 1e02df1f61f..a19933a8c3c 100644 --- a/docs/reference/migration/migrate_6_0/rest.asciidoc +++ b/docs/reference/migration/migrate_6_0/rest.asciidoc @@ -7,3 +7,7 @@ In previous versions of Elasticsearch, JSON documents were allowed to contain un This feature was removed in the 5.x series, but a backwards-compability layer was added via the system property `elasticsearch.json.allow_unquoted_field_names`. This backwards-compability layer has been removed in Elasticsearch 6.0.0. + +==== Analyze API changes + +The deprecated request parameters and plain text in request body has been removed, use JSON in request body. From 99236b76270d53f6cbe0870a93ae1986acdd2b6a Mon Sep 17 00:00:00 2001 From: Jun Ohtani Date: Sun, 2 Oct 2016 04:23:07 +0900 Subject: [PATCH 3/4] Removing request parameters in _analyze API Fix small English issue in breaking changes Closes #20246 --- docs/reference/migration/migrate_6_0/rest.asciidoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/reference/migration/migrate_6_0/rest.asciidoc b/docs/reference/migration/migrate_6_0/rest.asciidoc index a19933a8c3c..74974969e43 100644 --- a/docs/reference/migration/migrate_6_0/rest.asciidoc +++ b/docs/reference/migration/migrate_6_0/rest.asciidoc @@ -10,4 +10,4 @@ has been removed in Elasticsearch 6.0.0. ==== Analyze API changes -The deprecated request parameters and plain text in request body has been removed, use JSON in request body. +The deprecated request parameters and plain text in request body has been removed. Use JSON in request body. From 945fa499d223261fffc89c732f340ad112ae58d7 Mon Sep 17 00:00:00 2001 From: Jun Ohtani Date: Wed, 5 Oct 2016 19:13:33 +0900 Subject: [PATCH 4/4] Deprecating request parameters in _analyze API Remove params in indices.analyze.json Fix REST changes Closes #20246 --- .../migration/migrate_6_0/rest.asciidoc | 2 +- .../rest-api-spec/api/indices.analyze.json | 34 +------------------ 2 files changed, 2 insertions(+), 34 deletions(-) diff --git a/docs/reference/migration/migrate_6_0/rest.asciidoc b/docs/reference/migration/migrate_6_0/rest.asciidoc index 74974969e43..7e2c0cb1cae 100644 --- a/docs/reference/migration/migrate_6_0/rest.asciidoc +++ b/docs/reference/migration/migrate_6_0/rest.asciidoc @@ -10,4 +10,4 @@ has been removed in Elasticsearch 6.0.0. ==== Analyze API changes -The deprecated request parameters and plain text in request body has been removed. Use JSON in request body. +The deprecated request parameters and plain text in request body has been removed. Define parameters in request body. diff --git a/rest-api-spec/src/main/resources/rest-api-spec/api/indices.analyze.json b/rest-api-spec/src/main/resources/rest-api-spec/api/indices.analyze.json index 881382ffa00..93965388916 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/api/indices.analyze.json +++ b/rest-api-spec/src/main/resources/rest-api-spec/api/indices.analyze.json @@ -12,22 +12,6 @@ } }, "params": { - "analyzer": { - "type" : "string", - "description" : "The name of the analyzer to use" - }, - "char_filter": { - "type" : "list", - "description" : "A comma-separated list of character filters to use for the analysis" - }, - "field": { - "type" : "string", - "description" : "Use the analyzer configured for this field (instead of passing the analyzer name)" - }, - "filter": { - "type" : "list", - "description" : "A comma-separated list of filters to use for the analysis" - }, "index": { "type" : "string", "description" : "The name of the index to scope the operation" @@ -36,22 +20,6 @@ "type" : "boolean", "description" : "With `true`, specify that a local shard should be used if available, with `false`, use a random shard (default: true)" }, - "text": { - "type" : "list", - "description" : "The text on which the analysis should be performed (when request body is not used)" - }, - "tokenizer": { - "type" : "string", - "description" : "The name of the tokenizer to use for the analysis" - }, - "explain": { - "type" : "boolean", - "description" : "With `true`, outputs more advanced details. (default: false)" - }, - "attributes": { - "type" : "list", - "description" : "A comma-separated list of token attributes to output, this parameter works only with `explain=true`" - }, "format": { "type": "enum", "options" : ["detailed","text"], @@ -61,7 +29,7 @@ } }, "body": { - "description" : "The text on which the analysis should be performed" + "description" : "Define analyzer/tokenizer parameters and the text on which the analysis should be performed" } } }