I want to look for all the jackets that are blue (in the "name" and "tags" fields).
But the color blue has many shades.
How do I implement the dictionary of synonyms?
(I tried many things, without conclusive results with a multitude of depreciation and errors.)
I currently use version 7.8 and the ability to update to 7.15.
References
#"analysis/synonym.txt"
# these colors are synonymous
cyan, cobalt, blue, pacific blue
PUT /test_index
{
"settings": {
"number_of_shards": 1,
"number_of_replicas": 0
},
"mappings": {
"properties": {
"name": {
"type": "text"
},
"tags": {
"type": "text"
},
"description": {
"type": "text"
},
"status": {
"type": "short"
}
}
}
}
POST _bulk
{ "index" : { "_index" : "test_index", "_id" : "1" } }
{"name": "Product blue jacket XXL", "tags": ["blue", "jacket", "tag1"], "status": 1, "description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit."}
{ "index" : { "_index" : "test_index", "_id" : "2" } }
{"name": "Product cyan jacket", "tags": ["cyan", "jacket", "tag2"], "status": 1, "description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit."}
{ "index" : { "_index" : "test_index", "_id" : "3" } }
{"name": "Product cobalt jacket", "tags": ["cobalt", "jacket", "tag2"], "status": 1, "description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit."}
{ "index" : { "_index" : "test_index", "_id" : "4" } }
{"name": "Product crystal blue", "tags": ["blue", "crystal", "tag4"], "status": 1, "description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit."}
{ "index" : { "_index" : "test_index", "_id" : "5" } }
{"name": "Product five", "tags": ["blue", "red", "tag5"], "status": 1, "description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit."}
{ "index" : { "_index" : "test_index", "_id" : "6" } }
{"name": "Product blue large jacket", "tags": ["blue", "jacket", "tag6"], "status": 2, "description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit."}
GET test_index/_search/
{
"query": {
"bool": {
"filter": [
{
"term": {
"status": 1
}
}
],
"must": {
"multi_match": {
"query": "blue jacket",
"type": "best_fields",
"fields": [
"tags^10",
"name^1"
],
"tie_breaker": 0.3,
"operator": "and"
}
}
}
},
"sort": {
"_score": "desc"
}
}
I want to thank you in advance