Wild card s not working as expected?

Hi I am trying the following query

curl -X GET "10.10.9.1:9200/_search?pretty" -H 'Content-Type: application/json' -d'
{
"query": {
"bool": {
"must": [
{ "term": { "campaign_id": "9cc8c9dc-c3a8-4f34-9736-ca6a0f6a04db" }},
{ "term": { "flight_id": "af387355-98f6-4c30-9f08-afe9ea06b72b" }},
{ "range": { "@timestamp": { "gte": "2015-01-01" }}}
],
"should" : {
"wildcard": { "recipient": { "value": "3400*" } }
}
}
}
}'

I would expect the above curl request not return any data as the recipient fields in the index all begins with 420. however it returns results .

{
"took" : 20,
"timed_out" : false,
"_shards" : {
"total" : 41,
"successful" : 41,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : 500,
"max_score" : 1.001997,
"hits" : [
{
"_index" : "mep-reports-2020.02.11",
"_type" : "doc",
"_id" : "af387355-98f6-4c30-9f08-afe9ea06b72b-5E426A00",
"_score" : 1.001997,
"_source" : {
"campaign_name" : "Irish Elections",
"nof_segments" : "1",
"msg_text" : "RM0 testhttps://is.gd/h3hkbm",
"@timestamp" : "2020-02-11T08:47:00.000Z",
"submission_ts" : "1581410820",
"campaign_id" : "9cc8c9dc-c3a8-4f34-9736-ca6a0f6a04db",
"flight_id" : "af387355-98f6-4c30-9f08-afe9ea06b72b",
"flight_name" : "Flight Tuesday 21",
"recipient" : "420736315250",
"inventory" : "SMS",
"delivery_ts" : "1581410824",
"@version" : "1",
"status" : "DELIVERED",
"o_error" : "INTERNAL_SUCCESS",
"sender" : "800111",
"account_id" : "270d13e6-2f4f-4d51-99d5-92ffba5f0cb6"
}
}
}

any idea why it happens . i would expect no data should be returned becuase the wild card search for 3400*

i found the answer

curl -X GET "10.10.9.1:9200/_search?pretty" -H 'Content-Type: application/json' -d'
{
"query": {

 "bool": {

   "must": [
    { "term":  { "campaign_id": "9cc8c9dc-c3a8-4f34-9736-ca6a0f6a04db" }},
{ "term":  { "flight_id": "af387355-98f6-4c30-9f08-afe9ea06b72b" }},
    { "range": { "@timestamp": { "gte": "2015-01-01" }}},
    { "wildcard": { "recipient": { "value": "3400*" } } }
  ]

}
}
}'

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