I want to perform an exact match on elasticsearch but the exact match should be on document not on the search string. for example:
I created this index:
PUT /indexName
{
"mappings": {
"properties": {
"name": {
"type": "text"
}
}
}
}
POST /indexName/_doc
{
"name": "City"
}
POST /indexName/_doc
{
"name": "City Lab"
}
now I want to perform search like this:
-if I search for(“City”), I want to get the first document only, and the second one should not match because (“City”) didn’t mathc the whole (“City Lab”).
-if I search for (“City Lab”), I want to get the second document and the first documnet becuase it it matches both of them as full exact match.
-if I search for (“where is the Citly Lab”), we have (“City”) and we have (“City Lab”), so I want to get also both of them.
-if I search for (“lab”), I will get 0 hit becasue lab didn’t match any.
-if I search for (“I am inside the city, then I will go to the lab”), I should get first document only only, (“city”) is a exact match, but (“I am inside the city, then I will go to the lab“) (“city … lab”), (“Lab”) wasn’t dircetly after (“City”) so it is not a match.
How to do that in elasticsearch?