this elastic search query fetching id
curl -xget localhost:9200/test-index2/business/_search -d' { "query" : { "filtered" : { "query" : { "match_all" : {} }, "filter" : { "term" : { "_id" : "au6lqk0wcsy7hkqgengx" } } } } }' and part of response
{"contactnumber": "+1-415-392-3702", "name": "golden gate hotel"} i've got contactnumber , name
now second query -> i'm querying 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 contactnumber , name field.
what doing wrong??
i should getting exact same record back
edit:
attaching mapping contact number
{"test-index2":{"mappings":{"business":{"properties":{"address":{"type":"string"},"contactnumber":{"type":"string","store":true},"name":{"type":"string"}}}}}}
term filter doesn't analyze input text, meaning if search "+1-415-392-3702" exact text it's expecting find in index.
but, field being default string means uses standard analyzer analyzing it. means in index you'll have these tokens: "1","3702","392","415" , not single +1-415-392-3702.
so, need either 1 of these two:
"contactnumber": { "type": "string", "index": "not_analyzed", "store":true } or
"contactnumber": { "type": "string", "analyzer": "keyword", "store":true }
Comments
Post a Comment