0
votes

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.

1

1 Answers

1
votes

Did you override the type mappings in Liferay?

Try to find liferay-type-mappings.json. Copy and past the full contents and modify the fields where you want to use the synonym_analyzer.

Eg.

"title_en_US": {
    "store": true,
    "term_vector": "with_positions_offsets",
    "type": "text",
    "search_analyzer" : "synonym_analyzer",
    "analyzer" : "synonym_analyzer"
},

Then put this whole modified mapping in the 'Override type mappings' field