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")

1 Answer 1

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"
      }
    }
  }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.