We have product details which contain length parameter which has value as 45"(45 inch) So on indexing this product details I am converting 45" to encoded string ie 45" ;
So on search i will send the search parameter encoded ie if user search product on 45" i will send it as 45". But elastic search doesn't give any result.
This filed in product details is mapped as -
product_length is array
"properties": {
"product_length": {
"type": "text",
"fields": {
"raw": {
"type": "keyword"
}
},
"fielddata": true
}
}
and to find products which have product length 45" i am using bellow query:
Search term is encoded before search ie 45" to 45" ;
{
"query": {
"bool": {
"must": [{
"terms": {
"product_length": ["45" ;"]
}
}]
}
}
}
result:
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 0,
"max_score": null,
"hits":
}
}
But it return's: "hits":
Is there another way I should follow?