"Designing an index in Elasticsearch so that "&" and "and" in query returns same result"
How can we make Elasticsearch return same results whether the search was made with "and" as the query string or ampersand "&".
For example there's a query to look for all movie titles containing "and / &" in their name.
- Mr. & Mrs. Smith
- Jack and Jill
- Abc and Def & ghi
- Dummy Name
So in this case it shouldn't matter if the search is done with "and" or "&" in query should return 1,2,3.
Dump from my Kibana Dev Tool
PUT test_index { "settings": {"number_of_replicas": 0, "number_of_shards": 1 }, "mappings": { "doc": { "properties": { "movie_name":{"type":"text"} } } } }
PUT /test_index/doc/1 { "movie_name":"Mr. & Mrs. Smith" }
PUT /test_index/doc/2 { "movie_name":"Jack and Jill" }
PUT /test_index/doc/3 { "movie_name":"Abc and Def & ghi" }
PUT /test_index/doc/4 { "movie_name":"Dummy Name" }
Both the queries below should return the same result
GET test_index/_search { "size": 20, "query": { "match": { "movie_name": "&" } } }
GET test_index/_search { "size": 20, "query": { "match": { "movie_name": "and" } } }