0

HI iam using the following query with bool must

{
  "query": { 
  "bool" : {
    "must" : [ {
      "match" : {
        "orgid" : {
          "query" : 13831,
          "type" : "boolean"
        }
      }
    }, {
      "query_string" : {
        "query" : "*07* AND *fres*"
      }
    } ]
  }
}
}

It's hitting null even though there documents with org id as 13831 & in documents there is one data in all fields as 07 and fres.Is anything wrong in this query

1 Answer 1

1

Edit: A problem might be you're using a match query instead of a term query. Term queries are used for exact matches. The following will filter the result set to only the org_id you want, and it will then look for 07 and fres. Please give it a try.

"query": {
    "bool" : {
      "must" : {
        "query_string" : {
          "query" : "*07* AND *fres*"
         }
      },
      "filter": {
        "term" : { "orgid" : 13831 }
      }
    }
  }
Sign up to request clarification or add additional context in comments.

4 Comments

Thanks for your suggestion, but my need is to get the documents with orgid:13831 AND that document must also contain characters like 07 AND fres in any of the fields in that document
if i wrote the above query as "orgid" : 13831 } it will return all the documents in which orgid is 13831 but how about the 07 AND fres condition
I didn't say to remove the other condition. What does this return: { "query": { "bool" : { "must" : [ { "match" : { "orgid" : 13831 } }, { "query_string" : { "query" : "*07* AND *fres*" } } ] } } }
Thanks, pqqash.....Both query worked i was checking with wrong orgId,even my query was fine it was just a wrong orId ,Thank for your help

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.