javanna commented on code in PR #16966: URL: https://github.com/apache/lucene/pull/16966#discussion_r4466556354
########## lucene/analysis/common/src/java/org/apache/lucene/analysis/miscellaneous/HyphenatedWordsFilter.java: ########## @@ -43,7 +42,6 @@ * </analyzer> * <analyzer type="query"> * <tokenizer class="solr.WhitespaceTokenizerFactory"/> - * <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/> Review Comment: Should these lines get removed or replaced? ########## lucene/MIGRATE.md: ########## @@ -34,6 +34,33 @@ The deprecated `FixBrokenOffsetsFilter` and its factory (SPI name `fixBrokenOffs Offsets that go backwards are rejected at index time; fix the upstream token filter or tokenizer that produces them instead. +### SynonymFilter and SynonymFilterFactory have been removed (GITHUB#16966) + +The deprecated `SynonymFilter` and its factory (SPI name `synonym`) are gone. Use +`SynonymGraphFilter` and `SynonymGraphFilterFactory` (SPI name `synonymGraph`), which accept the +same `SynonymMap` and factory arguments. `SynonymFilter.TYPE_SYNONYM` is now +`SynonymGraphFilter.TYPE_SYNONYM` (same value, `"SYNONYM"`). A `TokenFilterFactory` lookup of the +name `synonym` now throws `IllegalArgumentException`. + +`SynonymGraphFilter` is not a drop-in replacement; its output differs: + +- It produces a token graph, with correct position lengths for multi-token synonyms. The indexer + cannot consume a graph, so at index time follow it with `FlattenGraphFilter`; at query time use + the graph directly. +- Synonyms are emitted before the original token at the same position, not after it. +- Position increments and position lengths of multi-token synonyms differ from `SynonymFilter`, + which produced incorrect graphs for them. For example, for the input `spider man` with the rule + `spider man, spiderman`, `SynonymFilter` emitted `spider, spiderman, man` and + `SynonymGraphFilter` emits `spiderman, spider, man` with position lengths `2, 1, 1`. + +Existing indexes: the index format is unchanged, but analysis is rebuilt from your configuration +when an index is opened, so any analyzer that names `synonym` must be changed before upgrading. +Documents indexed with `SynonymFilter` keep their old positions. Documents indexed afterwards get Review Comment: I wonder if we should shorten this to say that existing indices relying on the removed functionality need to be reindexed. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
