From 63c4a214db3a9d30dde9d255e0887c47b2f6ee3e Mon Sep 17 00:00:00 2001 From: Matt Weber Date: Fri, 1 May 2015 21:36:27 -0700 Subject: [PATCH] document and test custom analyzer position offset gap --- docs/reference/analysis/analyzers/custom-analyzer.asciidoc | 4 ++++ .../elasticsearch/index/analysis/AnalysisModuleTests.java | 6 ++++++ src/test/java/org/elasticsearch/index/analysis/test1.json | 4 ++++ src/test/java/org/elasticsearch/index/analysis/test1.yml | 5 +++-- 4 files changed, 17 insertions(+), 2 deletions(-) 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 81f06ad79d7..0ce7ed466ff 100644 --- a/src/test/java/org/elasticsearch/index/analysis/AnalysisModuleTests.java +++ b/src/test/java/org/elasticsearch/index/analysis/AnalysisModuleTests.java @@ -152,6 +152,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]