Should field mapping boosting with wildcard term (e.g. term*) work?

Hi,

Have searched for boost related posts but cant find anything specific to this. I've added field level boosting to my field mapping. So in simple terms my raw mapping looks like this:

{
   "properties":{
     "title":{
      "type":"text",
      "boost":3
      },
     "content":{
      "type":"text"
     }
   }
}

If I query the index with the document type I'm looking for and a non wildcarded search term the results are boosted exactly as I'd expect. So my search term is "+nodeName:news +cat". If cat is in the title the results are boosted which is what I want. If I add an asterisks to the end of the term so the search term becomes "+nodeName:news +cat*" the boost is not applied.

I've also tried a search term of "+nodeName:news +(cat cat*)", in this scenario exact match items are ordered by boost but the wildcarded ones are just appended to the end of the results.

Is it possible to have index mapping boost with a wildcarded search term work?

Apologies if this lacks enough information I'm relatively new to Elastic so just doing some trial and error at the moment.

So after some more digging the solution seems to be rewrite: scoring_boolean

{"size": 20, "query":{"bool":{"must":[{"query_string":{"query":"+nodeName:news +(cat* cat)", "rewrite": "scoring_boolean" }}]}}}

Documentation here https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-multi-term-rewrite.html. I need to read up on what rewrite is doing, but thought I'd post that I'd solved this anyway :slight_smile:

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.