How can I get the data if 3 conditions are met


(Sannthosh) #1

Hi Team
I am firing below must match query. I need the data if below 3 conditions are met

GET /std_index/std_type/_search
{"query":{
    "bool":
      {"must":[
          {"match":{"std_id":"10002"}},
          {"match":{"user_type":"2"}},
          {"match":{"email_adr":"new90suneelmail@some.com"}}
          ]
      }
  }
}

But It's fetching data even three match conditions not yet met.
out put is

{
  "took": 16,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "failed": 0
  },
  "hits": {
    "total": 1,
    "max_score": 0.5457982,
    "hits": [
      {
        "_index": "std_index",
        "_type": "std_type",
        "_id": "AV3glvaiYewAq_K9goWm",
        "_score": 0.5457982,
        "_source": {
          "user_created_by": "skodari",
          "create_tms": "2017-08-14T07:52:56.174Z",
          "exp_tms": "2017-08-14T09:06:55.007Z",
          "first_name": "NeBayya",
          "last_name": "NeSuneel",
          "email_adr": "new4suneelmail@some.com",
          "sms_adr": "fresh.att.net",
          "std_id": "10002",
          "user_type": "2",
        }
      }
    ]
  }
}

may I know why we are getting this record, even the
{"match":{"email_adr":"new90suneelmail@some.com"}}
condition not yet met ?
can anyone please help into this ?
Thanks Preformatted text


(Arthur Gimpel) #2

Hi,
Is the email_adr field analyzed? Check by running
GET http://elasticsearch:9200/std_index/_mapping

Also, try to change the "match" to "filter".


(Sannthosh) #3

Thanks
If I am trying with the filter I am getting same out put.

If I try with above link I am getting below value for "email_adr"
"email_adr":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}}

is this okay ? or Am I wrong ?

Thanks


(Arthur Gimpel) #4

Try to run the same with filter, and "email_adr.keyword" instead of email_adr.


(Sannthosh) #5

ohh great !!! thanks Arthur


(Arthur Gimpel) #6

You're welcome!


(system) #7

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.