somethingyouwant
somethingyouwant

Reputation: 161

Elastic Search - Field weight (for boosting) in mapping

I know we can boost a field like this while making a search query in Elastic Search. Can we do this in mapping by giving a field extra weight?

GET /_search
{
    "query": {
        "function_score": {
            "field_value_factor": {
                "field": "likes",
                "factor": 1.2,
                "modifier": "sqrt",
                "missing": 1
            }
        }
    }
}

Upvotes: 0

Views: 1360

Answers (2)

somethingyouwant
somethingyouwant

Reputation: 161

Index time boosting boosting is deprecated in ElasticSearch 5.x and not suggested anymore.

If you want boosting just do it in search time.

Upvotes: 0

Val
Val

Reputation: 217274

Yes, you can do that using the boost setting in your field declaration:

PUT my_index
{
  "mappings": {
    "_doc": {
      "properties": {
        "likes": {
          "type": "integer",
          "boost": 1.2                  <--- add this
        }
      }
    }
  }
}

Upvotes: 1

Related Questions