Elasticsearch: Unable to assign different boost values for same-named fields
See original GitHub issueThe following definition is valid for Elasticsearch 1., but invalid for 2.:
search_fields = Page.search_fields + [
index.SearchField('title', partial_match=True, boost=10),
index.SearchField('intro'),
index.SearchField('body'),
]
With Elasticsearch 2 it causes the following error:
Mapper for [title] conflicts with existing mapping in other types:\n[mapper [title] has different [analyzer], mapper [title] is used by multiple types. Set update_all_types to true to update [boost] across all types.
I think we need to mention it somehow in documentation (maybe in the “Upgrade considerations” section?).
Important! The same issue can be reproduced with wagtail.wagtailadmin.taggable.TagSearchable
. This class is deprecated, but will be removed only in Wagtail 1.8. That’s why I marked this issue as “Release blocker”.
Refs:
(cc @kaedroho)
Issue Analytics
- State:
- Created 7 years ago
- Comments:9 (6 by maintainers)
Top Results From Across the Web
Different boosting for the same field in different types in ...
So my question is, how can I do that boosting for the title, just for the type blog_t1, and not blog_t2, with Elasticsearch...
Read more >Relevance Tuning Guide, Weights and Boosts - Elastic
Relevance Tuning is changing how fields are weighted against one another or boosting relevance given a value within a field.
Read more >boost | Elasticsearch Guide [7.17] | Elastic
You cannot change index-time boost values without reindexing all of your documents. Every query supports query-time boosting which achieves the same effect.
Read more >Boosting query | Elasticsearch Guide [8.5] | Elastic
Elastic Cloud. Maximize value and optimize your experience. Deploy everything Elastic has to offer across any cloud, in minutes.
Read more >Apply Boosting Based on a Field Value - Elasticsearch
When choosing the latter, other scores will then either be summed (boolean query) or a max is chosen (dismax). (if this is too...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Resolving this issue isn’t trivial, and it only affects ES1, which has been EOL since Janurary. We have good support for ES2 and ES5 so I think we should leave this one. Those who are affected by this issue should upgrade Elasticsearch.
One thing that might make implementing the query-time boost simpler could be to split the _all field into four separate fields for different rank levels. Eeach field is indexed twice, once with the usual field name and again in the global field that has the closest rank value.
When querying “all” fields, we query these four fields together setting the rank on the query.
This is basically how PostgreSQL FTS does ranking so restricting Wagtail to four levels of ranking should make it easier to integrate with that.
For example, the mapping of a page could be as follows:
When querying all pages, we only query the
rank_*
fields as we are not aware of any specific fields for all pages:And when querying specific fields directly, we could look up the actual rank of the field manually:
This solves the problem with clashing boosts, it removes the need for index-time boosting (which makes field-length norms more accurate) and it also simplifies the ranking in Wagtail enough to make it fit much better with Postgres FTS.