prasad kp
prasad kp

Reputation: 861

Query string embeded with bool query

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

Upvotes: 0

Views: 1611

Answers (1)

paqash
paqash

Reputation: 2314

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 }
      }
    }
  }

Upvotes: 1

Related Questions