I am using elasticsearch 7.0.0
.
I am trying to work on synonyms
with this configuration while creating index
.
{
"settings": {
"index": {
"analysis": {
"analyzer": {
"synonym": {
"tokenizer": "whitespace",
"filter": [
"synonym"
]
}
},
"filter": {
"synonym": {
"type": "synonym",
"synonyms_path": "synonyms.txt"
}
}
}
}
},
"mappings": {
"properties": {
"address.state": {
"type": "text",
"analyzer": "synonym"
},
"location": {
"type": "geo_point"
}
}
}
}
Here's a document inserted into the index:
{
"name": "Berry's Burritos",
"description": "Best burritos in New York",
"address": {
"street": "230 W 4th St",
"city": "New York",
"state": "NY",
"zip": "10014"
},
"location": [
40.7543385,
-73.976313
],
"tags": [
"mexican",
"tacos",
"burritos"
],
"rating": "4.3"
}
Also content in synonyms.txt
:
ny, new york, big apple
When I tried searching for anything in address.state
property, I get empty
result.
Here's the query:
{
"query": {
"bool": {
"filter": {
"range": {
"rating": {
"gte": 4
}
}
},
"must": {
"match": {
"address.state": "ny"
}
}
}
}
}
Even with ny
(as it is:no synonym) in query, the result is empty.
Before, when I created index without mappings
, the query used to give the result, only except for synonyms.
But now with mappings
, the result is empty even though the term is present.
This query is working though: { "query": { "query_string": { "query": "tacos", "fields": [ "tags" ] } } }
I looked and researched into many articles/tutorials and came up this far.
What am I missing here now?