Suppose i\'ve 3 doc
doc_1 = {
"citedIn": [
"Bar Councils Act, 1926 - Section 15",
"Contract Act, 1872 - Section 23&qu
There is no way for you to achieve this as what you are indexing is a array to strings in your citedIn
field, and as all Elasticsearch fields are multi-valued by default as it was designed in Lucene that way, and elasticsearch is built on top of Lucene search library.
Please read arrays in elasticsearch for more info, especially the last important note as shown in below image:
As explained in above image, all your strings in your array actually part of same field, hence there is no way for ES to identify whether your search string was part of same string in array or not, due to which you were getting all the docs in search.
Unless you index these strings as part of another fields like nested
fields, but for that you need to give the name of fields and its like a map where key is your field name and value is field value and than you query on field names, you wouldn't be able to achieve your use-case.