Search code examples
elasticsearchfieldsolr-boost

Elasticsearch: Boost the field for specific values using Mappings


I am using elasticsearch Version 5.6. I would like to like to boost the field "type" when it's value is video ( "contentType": "video"). Currently my mappings looks like this:

PUT my_index
{
  "mappings": {
    "my_type": {
      "properties": {
        "title": {
          "type": "text", 
        },
        "contentType": {
          "type": "text",
           "boost": 4
        }
      }
    }
  }
}

How can I specify that only boost by 4 where contentType is equal to "video"? I know it can be done on query side, but I would like to do it in my mappings. Is it possible? Any help is appreciated


Solution

  • In elastic 2.x is possible, https://www.elastic.co/guide/en/elasticsearch/reference/2.3/index-boost.html It's deprecated since 5.0 https://www.elastic.co/guide/en/elasticsearch/reference/6.0/mapping-boost.html. Take a look to the section why index time boosting is a bad idea