We have a custom search portlet in Liferay DXP and Elasticsearch 2.2.0. We added the following settings for synonyms search in elasticsearch setting.
{
"index" : {
"analysis" : {
"analyzer" : {
"synonym" : {
"tokenizer" : "whitespace",
"filter" : ["synonym"]
}
},
"filter" : {
"synonym" : {
"type" : "synonym",
"synonyms_path" : "analysis/synonym.txt"
}
}
}
}}
We also verified whether the synonym analyzer is added to the index using the following code.
curl -XPOST 'localhost:9200/liferay-20116/_analyze?pretty' -H 'Content-Type: application/json' -d'
{
"analyzer": "synonym",
"text": "acl"
}
'
This gives the result of all synonyms of "acl" from the synonyms.txt file. But the Liferay search doesn't give the search hits with synonyms. for ex: search("acl") => gives no results with its synonyms in the synonyms.txt file.