Skip to content

Commit

Permalink
Deprecate CamelCase PathHierarchy tokenizer name
Browse files Browse the repository at this point in the history
Deprecate CamelCase PathHierarchy tokenizer name in favor to lowercase path_hierarchy.

Signed-off-by: Lukáš Vlček <[email protected]>
  • Loading branch information
lukas-vlcek committed Oct 26, 2023
1 parent 746ca09 commit 3e03262
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 28 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Return 409 Conflict HTTP status instead of 503 on failure to concurrently execute snapshots ([#8986](https://github.com/opensearch-project/OpenSearch/pull/5855))
- Add task completion count in search backpressure stats API ([#10028](https://github.com/opensearch-project/OpenSearch/pull/10028/))
- Performance improvement for Datetime field caching ([#4558](https://github.com/opensearch-project/OpenSearch/issues/4558))
- Deprecate CamelCase `PathHierarchy` tokenizer name in favor to lowercase `path_hierarchy` ([#10894](https://github.com/opensearch-project/OpenSearch/pull/10894))


### Deprecated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,21 @@ public Map<String, AnalysisProvider<TokenizerFactory>> getTokenizers() {
// TODO deprecate and remove in API
tokenizers.put("lowercase", XLowerCaseTokenizerFactory::new);
tokenizers.put("path_hierarchy", PathHierarchyTokenizerFactory::new);
tokenizers.put("PathHierarchy", PathHierarchyTokenizerFactory::new);
tokenizers.put("PathHierarchy", (IndexSettings indexSettings, Environment environment, String name, Settings settings) -> {
if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_3_0_0)) {
throw new IllegalArgumentException(

Check warning on line 399 in modules/analysis-common/src/main/java/org/opensearch/analysis/common/CommonAnalysisModulePlugin.java

View check run for this annotation

Codecov / codecov/patch

modules/analysis-common/src/main/java/org/opensearch/analysis/common/CommonAnalysisModulePlugin.java#L399

Added line #L399 was not covered by tests
"The [PathHierarchy] tokenizer name was deprecated. "
+ "Please change the tokenizer name to [path_hierarchy] for indices created in versions 3.0 or higher instead."
);
} else {
deprecationLogger.deprecate(

Check warning on line 404 in modules/analysis-common/src/main/java/org/opensearch/analysis/common/CommonAnalysisModulePlugin.java

View check run for this annotation

Codecov / codecov/patch

modules/analysis-common/src/main/java/org/opensearch/analysis/common/CommonAnalysisModulePlugin.java#L404

Added line #L404 was not covered by tests
"PathHierarchy_tokenizer_deprecation",
"The [PathHierarchy] tokenizer name is deprecated and will be removed in a future version. "
+ "Please change the tokenizer name to [path_hierarchy] instead."
);
}
return new PathHierarchyTokenizerFactory(indexSettings, environment, name, settings);

Check warning on line 410 in modules/analysis-common/src/main/java/org/opensearch/analysis/common/CommonAnalysisModulePlugin.java

View check run for this annotation

Codecov / codecov/patch

modules/analysis-common/src/main/java/org/opensearch/analysis/common/CommonAnalysisModulePlugin.java#L410

Added line #L410 was not covered by tests
});
tokenizers.put("pattern", PatternTokenizerFactory::new);
tokenizers.put("uax_url_email", UAX29URLEmailTokenizerFactory::new);
tokenizers.put("whitespace", WhitespaceTokenizerFactory::new);
Expand Down Expand Up @@ -662,8 +676,21 @@ public List<PreConfiguredTokenizer> getPreConfiguredTokenizers() {
}
return new EdgeNGramTokenizer(NGramTokenizer.DEFAULT_MIN_NGRAM_SIZE, NGramTokenizer.DEFAULT_MAX_NGRAM_SIZE);
}));
tokenizers.add(PreConfiguredTokenizer.singleton("PathHierarchy", PathHierarchyTokenizer::new));

tokenizers.add(PreConfiguredTokenizer.openSearchVersion("PathHierarchy", (version) -> {
if (version.onOrAfter(Version.V_3_0_0)) {
throw new IllegalArgumentException(

Check warning on line 681 in modules/analysis-common/src/main/java/org/opensearch/analysis/common/CommonAnalysisModulePlugin.java

View check run for this annotation

Codecov / codecov/patch

modules/analysis-common/src/main/java/org/opensearch/analysis/common/CommonAnalysisModulePlugin.java#L681

Added line #L681 was not covered by tests
"The [PathHierarchy] tokenizer name was deprecated. "
+ "Please change the tokenizer name to [path_hierarchy] for indices created in versions 3.0 or higher instead."
);
} else {
deprecationLogger.deprecate(

Check warning on line 686 in modules/analysis-common/src/main/java/org/opensearch/analysis/common/CommonAnalysisModulePlugin.java

View check run for this annotation

Codecov / codecov/patch

modules/analysis-common/src/main/java/org/opensearch/analysis/common/CommonAnalysisModulePlugin.java#L686

Added line #L686 was not covered by tests
"PathHierarchy_tokenizer_deprecation",
"The [PathHierarchy] tokenizer name is deprecated and will be removed in a future version. "
+ "Please change the tokenizer name to [path_hierarchy] instead."
);
}
return new PathHierarchyTokenizer();

Check warning on line 692 in modules/analysis-common/src/main/java/org/opensearch/analysis/common/CommonAnalysisModulePlugin.java

View check run for this annotation

Codecov / codecov/patch

modules/analysis-common/src/main/java/org/opensearch/analysis/common/CommonAnalysisModulePlugin.java#L692

Added line #L692 was not covered by tests
}));
return tokenizers;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -311,19 +311,6 @@
- match: { detail.tokenizer.tokens.1.token: a/b }
- match: { detail.tokenizer.tokens.2.token: a/b/c }

- do:
indices.analyze:
body:
text: "a/b/c"
explain: true
tokenizer:
type: PathHierarchy
- length: { detail.tokenizer.tokens: 3 }
- match: { detail.tokenizer.name: __anonymous__PathHierarchy }
- match: { detail.tokenizer.tokens.0.token: a }
- match: { detail.tokenizer.tokens.1.token: a/b }
- match: { detail.tokenizer.tokens.2.token: a/b/c }

- do:
indices.analyze:
body:
Expand All @@ -336,18 +323,6 @@
- match: { detail.tokenizer.tokens.1.token: a/b }
- match: { detail.tokenizer.tokens.2.token: a/b/c }

- do:
indices.analyze:
body:
text: "a/b/c"
explain: true
tokenizer: PathHierarchy
- length: { detail.tokenizer.tokens: 3 }
- match: { detail.tokenizer.name: PathHierarchy }
- match: { detail.tokenizer.tokens.0.token: a }
- match: { detail.tokenizer.tokens.1.token: a/b }
- match: { detail.tokenizer.tokens.2.token: a/b/c }

---
"pattern":
- do:
Expand Down

0 comments on commit 3e03262

Please sign in to comment.