question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Elasticsearch: Unable to assign different boost values for same-named fields

See original GitHub issue

The 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:closed
  • Created 7 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
kaedrohocommented, Oct 19, 2017

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.

1reaction
kaedrohocommented, Sep 5, 2016

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:

{
    "properties" {
        "rank_a": {"type": "string"},
        "rank_b": {"type": "string"},
        "rank_c": {"type": "string"},
        "rank_d": {"type": "string"},
        "title": {"type": "string", "copy_to": "rank_a"},
        "body": {"type": "string", "copy_to": "rank_b"},
        "unimportant_field": {"type": "string", "copy_to": "rank_d"},
    }
}

When querying all pages, we only query the rank_* fields as we are not aware of any specific fields for all pages:

{
    "multi_match" : {
        "query": "hello world", 
        "fields": ["rank_a^1.0", "rank_b^0.7", "rank_c^0.5", "rank_d^0.1"] 
    }
}

And when querying specific fields directly, we could look up the actual rank of the field manually:

{
    "multi_match" : {
        "query": "hello world", 
        "fields": ["title^1.0", "body^0.8"] 
    }
}

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found