This is my elastic search query for fetching the id
curl -XGET localhost:9200/test-index2/business/_search -d'
{
"query" : {
"filtered" : {
"query" : {
"match_all" : {}
},
"filter" : {
"term" : {
"_id" : "AU6LqK0WCSY7HKQGengx"
}
}
}
}
}'
And this is part of the response
{"contactNumber": "+1-415-392-3702", "name": "Golden Gate Hotel"}
I've got the contactNumber and name
Now my second query -> i'm querying for the above contact number using term filter
curl -XGET localhost:9200/test-index2/business/_search -d'
{
"query" : {
"filtered" : {
"query" : {
"match_all" : {}
},
"filter" : {
"term" : {
"contactNumber" : "+1-415-392-3702"
}
}
}
}
}'
and i've got 0 hits!
I've indexed both the contactNumber and name field.
What am i doing wrong??
I should be getting the exact same record back
Edit:
Attaching the mapping for contact number
{"test-index2":{"mappings":{"business":{"properties":{"address":{"type":"string"},"contactNumber":{"type":"string","store":true},"name":{"type":"string"}}}}}}
contactNumber? - Andrei StefancontactNumbershould have ananalyzerthat doesn't change its content, for examplekeywordor it should benot_analyzed. - Andrei Stefan