Hi everybody.
I'm new here, learning the elasticsearch.
I want to be able to find a full sentence like "live usa" while "usa" is an synonyms of (usa,united states,u s a,united states of america"
if I search for only "usa" or "u s a" etc. It's found all the occurances, but if I search for "live usa" it;s found nothing.
// below my code.
PUT /my_index
{
"settings": {
"analysis": {
"filter": {
"my_synonym_filter": {
"type": "synonym",
"synonyms": [
"usa,united states,u s a,united states of america"
]
}
},
"analyzer": {
"my_synonyms": {
"tokenizer": "standard",
"filter": [
"lowercase",
"my_synonym_filter"
]
}
}
}
},
"mappings": {
"table1": {
"properties": {
"text": { "type": "text" ,"analyzer": "my_synonyms" }
}
}
}
}
POST /my_index/table1/_bulk
{ "index": { "_id":1}}
{"text":"I live in the usa"}
{ "index": { "_id":2}}
{"text":"the united states of america are pluralzse"}
{ "index": { "_id":3}}
{"text":"I want to visit canade"}
{ "index": { "_id":4}}
{"text":"can you go to the u s a?"}
GET /my_index/table1/_search
{
"query": {
"match_phrase": {
"text": {
"query": "usa",
"analyzer": "my_synonyms"
}
}
}
}
thanks in advance!
Ruti