0

I have a query as below using the query string dsl which I'm expecting to return results that match all the three assertions. (status = active, price = 100 , language = en).

How can I make the language param optional, just score lower if is not matching instead to not match at all ?

(status:"active") AND (price:100) AND (language:"en")
mike
  • 533
  • 1
  • 7
  • 24

1 Answers1

1

You can try this

(status:active AND language:en) OR (price:100 AND language:en)

Or a shorter version like this:

+status:active +price:100 language:en

An equivalent query rewritten using bool and match queries is this one:

{
  "bool": {
    "must": [
      {
        "match": {
          "status": "active"
        }
      },
      {
        "match": {
          "price": 100
        }
      }
    ],
    "should": {
      "match": {
        "language": "en"
      }
    }
  }
}
Val
  • 207,596
  • 13
  • 358
  • 360