Can a Boosting Query be applied to multiple values of a given field?

(John McGinty) #1

Hi guys,

Re 5.0 Boosting Queries

I'm interested in the best way to boost scores based on the importance of kinds of text (e.g. titles, comments), etc.

I'm experimenting with a mapping that uses a nested object containing 2 fields: text and weight, and I want to boost scores at query time based on the values of the weight field.

Is this possible with the "boosting" query? From results using the query below, I see that the docs that match the "positive" clause are boosted, but scores for other docs are unchanged. Am I doing something wrong?

  "query": {
    "bool": {
      "must": {
        "nested": {
          "path": "content",
          "score_mode": "avg",
          "query":  {
            "bool": {
                  {"match": {"content.text": "aid"} }
                 {"boosting": {
                    "positive": {
                      "term" : {"content.weight": 2}
                    "negative": {
                      "term" : {"content.weight": 0}
                    "negative_boost": 0.5

I have documents with weight values of 0,1,2; the only scores affected based on my tests are those with weight 2.


(Adrien Grand) #2

Given your use-case, it might be simpler and more flexible to use script_score.

(system) #3

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