1

I use these queries in elastic but the problem is when I replace values I get some different result or when I use each word individually we have different result.here is part of my queries

"query_string" : {
      "query" : "businessId : 1848 4335",
      "fields" : []
}
result : "hits": {"total": 81,....}

when replace businessIds:

"query_string" : {
      "query" : "businessId : 4335 1848",
      "fields" : []
}
result :  "hits": {"total": 162,...}

when I search "4335"

"query_string" : {
      "query" : "businessId : 4335",
      "fields" : []
}
result :  "hits": {"total": 0,...}

search "1848"

"query_string" : {
      "query" : "businessId : 1848",
      "fields" : []
}
result :  "hits": {"total": 14,...}

when I use "businessId" in fields

"query_string" : {
      "query" : "4335 1848",
      "fields" : ["businessId"]
}
result :  "hits": {"total": 14,...}

I am so confused why these results happened?

0

1 Answer 1

4

You can use a query string query like so:

{
  "query": {
    "query_string": {
      "query": "businessId:4335 OR businessId:1848"
    }
  }
}

or

{
  "query": {
    "query_string": {
      "query": "businessId:(4335 OR 1848)"
    }
  }
}
Sign up to request clarification or add additional context in comments.

2 Comments

thank you. but I know white space works as OR operator doesn't it?
Not sure about that one. I haven't seen your mapping... First of all, are we talking strings or numbers?

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.