0

I am trying to combine a range filter query, a bool-must-match query, and a constant score (terms) filter query all in one query. I have both the range filter query and the bool-must-match query combine so far:

{
  "query": {
    "bool": {
      "must": [
        {
          "match": {
            "market": "Android"
          }
        }
      ],
      "filter": [
        {
          "range": {
            "sold": {
              "gte": "20170601",
              "lte": "20170602"
            }
          }
        }
      ]
    }
  }
}

How do I add this query in there:

{
    "query" : {
        "constant_score" : {
            "filter" : {
                "terms" : { 
                    "price" : [200, 300]
                }
            }
        }
    }
}

Is there a way to combine all three together?

1 Answer 1

0

You can simply add it in the bool/filter section as filters have a constant score:

{
  "query": {
    "bool": {
      "must": [
        {
          "match": {
            "market": "Android"
          }
        }
      ],
      "filter": [
        {
          "terms": {
            "price": [
              200,
              300
            ]
          }
        },
        {
          "range": {
            "sold": {
              "gte": "20170601",
              "lte": "20170602"
            }
          }
        }
      ]
    }
  }
}
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.