Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Synonyms.bag is an alternate, simpler form of query expansion using the synonyms generated from the analysis chain. Instead of taking the query "dog bite" and expanding it to:
The synonyms simply get appended to the dismax query, and the generated synonym queries become
when "constructPhraseQueries" is set to true, the generated synonym queries become
which is desirable when synonyms expansion results in multiword phrases.
The advantage to synonyms.bag is improved performance. In some cases, with large queries and many synonyms, the default query expansion can grow extremely complex resulting in performance problems. Synonyms.bag simplifies this expansion dramatically.
The drawback is loss of positional information in the query string. Features such as pf2, pf3, etc that try parts of the query as phrases won't function as expected. By simply appending generated synonyms, position information within the query is not a useful indicator of phrases that were actually searched for.
Synonyms.bag is ideal for identifying entities/tags within queries and searching against tag-like fields. Positional information is not meaningful in these contexts, so simply searching a "bag" of synonyms makes a lot of sense.