diff --git a/docs/reference/analysis/analyzers/custom-analyzer.asciidoc b/docs/reference/analysis/analyzers/custom-analyzer.asciidoc index 5c778a6c83d..a7cf7136a83 100644 --- a/docs/reference/analysis/analyzers/custom-analyzer.asciidoc +++ b/docs/reference/analysis/analyzers/custom-analyzer.asciidoc @@ -18,6 +18,9 @@ filters. |`char_filter` |An optional list of logical / registered name of char filters. + +|`position_offset_gap` |An optional number of positions to increment +between each field value of a field using this analyzer. |======================================================================= Here is an example: @@ -32,6 +35,7 @@ index : tokenizer : myTokenizer1 filter : [myTokenFilter1, myTokenFilter2] char_filter : [my_html] + position_offset_gap: 256 tokenizer : myTokenizer1 : type : standard diff --git a/src/test/java/org/elasticsearch/index/analysis/AnalysisModuleTests.java b/src/test/java/org/elasticsearch/index/analysis/AnalysisModuleTests.java index 8fb9a29488f..ffe1d1b37dc 100644 --- a/src/test/java/org/elasticsearch/index/analysis/AnalysisModuleTests.java +++ b/src/test/java/org/elasticsearch/index/analysis/AnalysisModuleTests.java @@ -161,6 +161,12 @@ public class AnalysisModuleTests extends ElasticsearchTestCase { // html = (HtmlStripCharFilterFactory) custom2.charFilters()[1]; // assertThat(html.readAheadLimit(), equalTo(1024)); + // verify position offset gap + analyzer = analysisService.analyzer("custom6").analyzer(); + assertThat(analyzer, instanceOf(CustomAnalyzer.class)); + CustomAnalyzer custom6 = (CustomAnalyzer) analyzer; + assertThat(custom6.getPositionIncrementGap("any_string"), equalTo(256)); + // verify characters mapping analyzer = analysisService.analyzer("custom5").analyzer(); assertThat(analyzer, instanceOf(CustomAnalyzer.class)); diff --git a/src/test/java/org/elasticsearch/index/analysis/test1.json b/src/test/java/org/elasticsearch/index/analysis/test1.json index 3b503d1da76..69be6db8f82 100644 --- a/src/test/java/org/elasticsearch/index/analysis/test1.json +++ b/src/test/java/org/elasticsearch/index/analysis/test1.json @@ -66,6 +66,10 @@ "tokenizer":"standard", "char_filter":["my_mapping"] }, + "custom6":{ + "tokenizer":"standard", + "position_offset_gap": 256 + }, "czechAnalyzerWithStemmer":{ "tokenizer":"standard", "filter":["standard", "lowercase", "stop", "czech_stem"] diff --git a/src/test/java/org/elasticsearch/index/analysis/test1.yml b/src/test/java/org/elasticsearch/index/analysis/test1.yml index 9c4aac6a6cb..81ef2353103 100644 --- a/src/test/java/org/elasticsearch/index/analysis/test1.yml +++ b/src/test/java/org/elasticsearch/index/analysis/test1.yml @@ -49,7 +49,8 @@ index : tokenizer : standard char_filter : [my_mapping] custom6 : - type : standard + tokenizer : standard + position_offset_gap: 256 custom7 : type : standard version: 3.6 @@ -58,4 +59,4 @@ index : filter : [standard, lowercase, stop, czech_stem] decompoundingAnalyzer : tokenizer : standard - filter : [dict_dec] \ No newline at end of file + filter : [dict_dec]