Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace delimited_payload_filter by delimited_payload #26625

Merged
merged 8 commits into from
Nov 24, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,10 @@ public void testRandomPayloadWithDelimitedPayloadTokenFilter() throws IOExceptio
.field("analyzer", "payload_test").endObject().endObject().endObject().endObject();
Settings setting = Settings.builder()
.put("index.analysis.analyzer.payload_test.tokenizer", "whitespace")
.putList("index.analysis.analyzer.payload_test.filter", "my_delimited_payload_filter")
.put("index.analysis.filter.my_delimited_payload_filter.delimiter", delimiter)
.put("index.analysis.filter.my_delimited_payload_filter.encoding", encodingString)
.put("index.analysis.filter.my_delimited_payload_filter.type", "mock_payload_filter").build();
.putList("index.analysis.analyzer.payload_test.filter", "my_delimited_payload")
.put("index.analysis.filter.my_delimited_payload.delimiter", delimiter)
.put("index.analysis.filter.my_delimited_payload.encoding", encodingString)
.put("index.analysis.filter.my_delimited_payload.type", "mock_payload_filter").build();
createIndex("test", setting, "type1", mapping);

client().prepareIndex("test", "type1", Integer.toString(1))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[[analysis-delimited-payload-tokenfilter]]
=== Delimited Payload Token Filter

Named `delimited_payload_filter`. Splits tokens into tokens and payload whenever a delimiter character is found.
Named `delimited_payload`. Splits tokens into tokens and payload whenever a delimiter character is found.

Example: "the|1 quick|2 fox|3" is split by default into tokens `the`, `quick`, and `fox` with payloads `1`, `2`, and `3` respectively.

Expand Down
1 change: 1 addition & 0 deletions docs/reference/migration/migrate_7_0.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ way to reindex old indices is to use the `reindex` API.
* <<breaking_70_mappings_changes>>
* <<breaking_70_search_changes>>
* <<breaking_70_plugins_changes>>
* <<breaking_70_analysis_changes>>

include::migrate_7_0/aggregations.asciidoc[]
include::migrate_7_0/cluster.asciidoc[]
Expand Down
6 changes: 6 additions & 0 deletions docs/reference/migration/migrate_7_0/analysis.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[[breaking_70_analysis_changes]]
=== Analysis changes

==== The `delimited_payload_filter` is deprecated

The `delimited_payload_filter` is deprecated and should be replaced by `delimited_payload`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should make it clearer that the filter is just renamed, and its only the old name that is deprecated, something like "The delimited_payload_filter is renamed to delimited_payload, the old name is deprecated and will be removed at some point, so it should be replaces by delimited_payload" or slightly different.

Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ public Map<String, AnalysisProvider<TokenFilterFactory>> getTokenFilters() {
filters.put("czech_stem", CzechStemTokenFilterFactory::new);
filters.put("common_grams", requriesAnalysisSettings(CommonGramsTokenFilterFactory::new));
filters.put("decimal_digit", DecimalDigitFilterFactory::new);
// TODO deprecate delimited_payload_filter
filters.put("delimited_payload_filter", DelimitedPayloadTokenFilterFactory::new);
filters.put("delimited_payload", DelimitedPayloadTokenFilterFactory::new);
filters.put("dictionary_decompounder", requriesAnalysisSettings(DictionaryCompoundWordTokenFilterFactory::new));
filters.put("dutch_stem", DutchStemTokenFilterFactory::new);
filters.put("edge_ngram", EdgeNGramTokenFilterFactory::new);
Expand Down Expand Up @@ -191,10 +193,15 @@ public List<PreConfiguredTokenFilter> getPreConfiguredTokenFilters() {
input -> new CommonGramsFilter(input, CharArraySet.EMPTY_SET)));
filters.add(PreConfiguredTokenFilter.singleton("czech_stem", false, CzechStemFilter::new));
filters.add(PreConfiguredTokenFilter.singleton("decimal_digit", true, DecimalDigitFilter::new));
// TODO deprecate delimited_payload_filter
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the deprecation also needs to happen in this PR. Using the old name, either in the settings when creating an index or when using it in an already existing index should trigger a deprecation warning and an entry in the logs.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pushed 7e7c54d

filters.add(PreConfiguredTokenFilter.singleton("delimited_payload_filter", false, input ->
new DelimitedPayloadTokenFilter(input,
DelimitedPayloadTokenFilterFactory.DEFAULT_DELIMITER,
DelimitedPayloadTokenFilterFactory.DEFAULT_ENCODER)));
filters.add(PreConfiguredTokenFilter.singleton("delimited_payload", false, input ->
new DelimitedPayloadTokenFilter(input,
DelimitedPayloadTokenFilterFactory.DEFAULT_DELIMITER,
DelimitedPayloadTokenFilterFactory.DEFAULT_ENCODER)));
filters.add(PreConfiguredTokenFilter.singleton("dutch_stem", false, input -> new SnowballFilter(input, new DutchStemmer())));
filters.add(PreConfiguredTokenFilter.singleton("edge_ngram", false, input ->
new EdgeNGramTokenFilter(input, EdgeNGramTokenFilter.DEFAULT_MIN_GRAM_SIZE, EdgeNGramTokenFilter.DEFAULT_MAX_GRAM_SIZE)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,9 @@ protected Map<String, Class<?>> getPreConfiguredTokenFilters() {
filters.put("common_grams", null);
filters.put("czech_stem", null);
filters.put("decimal_digit", null);
// TODO deprecate delimited_payload_filter
filters.put("delimited_payload_filter", org.apache.lucene.analysis.payloads.DelimitedPayloadTokenFilterFactory.class);
filters.put("delimited_payload", org.apache.lucene.analysis.payloads.DelimitedPayloadTokenFilterFactory.class);
filters.put("dutch_stem", SnowballPorterFilterFactory.class);
filters.put("edge_ngram", null);
filters.put("edgeNGram", null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1026,6 +1026,7 @@
- match: { tokens.10.token: ちた }

---
# Deprecate delimited_payload_filter
"delimited_payload_filter":
- do:
indices.create:
Expand Down Expand Up @@ -1058,6 +1059,39 @@
- length: { tokens: 1 }
- match: { tokens.0.token: foo }

---
"delimited_payload":
- do:
indices.create:
index: test
body:
settings:
analysis:
filter:
my_delimited_payload:
type: delimited_payload
delimiter: ^
encoding: identity
- do:
indices.analyze:
index: test
body:
text: foo^bar
tokenizer: keyword
filter: [my_delimited_payload]
- length: { tokens: 1 }
- match: { tokens.0.token: foo }

# Test pre-configured token filter too:
- do:
indices.analyze:
body:
text: foo|5
tokenizer: keyword
filter: [delimited_payload]
- length: { tokens: 1 }
- match: { tokens.0.token: foo }

---
"keep_filter":
- do:
Expand Down