Reindexing search indices deletes all Synonym Sets
Fix Priority
Components
Affects versions
Fix versions
Git Pull Request
Description
causes
fixes
is a dependency of
Activity
Tibor Lipusz June 17, 2020 at 2:10 AM
Included in Liferay Connector to Elasticsearch 7 v3.0.1.
Joshua Chong January 23, 2020 at 12:39 PM
Testing PASSED following the steps in the description. Synonym sets are not removed after reindexing and searching with synonyms still works.
Tested on:
Elasticsearch 6 and Elasticsearch 7
Portal git commit: 37f005749012687e05649b3d148b4ce40b55821e
Joshua Chong January 22, 2020 at 12:01 PM
Hey , are the sub-tasks linked to this ticket complete as well? I'm prevented from closing this ticket until those sub-tasks are also closed. Thanks!
Adam Brandizzi January 17, 2020 at 1:35 PM
I found the issue was still reproducible due to a mistake on new code. Working on it now.
Joshua Chong January 3, 2020 at 4:45 PM
Testing FAILED following the steps in the description. Synonym sets are removed after a reindex is performed. Searching using synonyms previously added does not work.
Additionally, if there are synonym sets created, and a reindex is executed, during the reindex the synonym portlet will become unavailable and the following stacktrace will appear in the console:
An easy way to test this is to 1) Add synonym sets and keep current browser window on Synonym page 2) In a new browser window execute a reindex 3) Switch back to Synonym window and constantly refresh the page.
Details
Details
Assignee
Reporter
Branch Version/s
Backported to Branch
Sprint
Story Points
Zendesk Support
Linked Tickets
Zendesk Support

Solution notes
When upgrading to a patch level where this issue is already fixed, upon portal startup, a new index will be created for each Virtual Instance (company) called
liferay-search-tuning-synonyms-liferay-<companyId>
where all existing Synonym Sets will be carried over to. Subsequent updates, deletions will be saved both to the index settings of the given Virtual Index and to the corresponding synonyms index. Synonym sets will be preserved across full reindex operations.Note: if you have applied the workaround described below in your environment, please remove the related settings from the "Additional Index Configurations" before the next full reindex.
----
Steps to reproduce
Navigate to Control Panel > Search Tuning > Synonyms
Create a Synonym Set with a single entry with the words "car" and "automobile"
Create a blog post with title "automobiles are useful" and content "i like automobiles"
Navigate to Control Panel > Configuration > Search
Reindex all search indices
Navigate to Control Panel > Search Tuning > Synonyms
Search for "car"
Expected Result
The Synonym Set created in step 2 is still present in step 6.
The blog entry appears in the search results from step 7.
Actual Result
The Synonym Set created in step 2 is not present anymore.
The blog entry does not appear in the results
Explanation
We store synonym sets directly into index settings themselves instead of a database or a separate index. When reindexing, we delete the old index and regenerate everything.
Workaround: Backup & preserve Synonym Sets through the "Additional Index Configurations" for the Elasticsearch connector
Backup and migrate existing Synonym sets - One company (Virtual Instance)
After you add/update/remove a Synonym Set, you can get the Index Settings for the given company through Elaticsearch's REST API which also contains the "analysis" settings with your synonym sets. Once you have this JSON you can put it to the "Additional Index Configurations" of the "Elasticsearch 6" on the System Settings so next time you execute a reindex your Synonym Sets will be re-added.
We assume you added 2 Synonyms Sets: "journal,article" and "liferay,company".
We assume your example company ID is "20096" (You can obtain it from the "Virtual Instances" on the Control Panel)
Get the Index Settings through the REST API:
Request
For example http://localhost:9200/liferay-20096/_settings
Response
Copy the "analysis" from the JSON
Go to Control Panel - System Settings - Search - Elasticsearch 6/7.
Add the JSON to "Additional Index Configurations", it looks something like this:
"Elasticsearch 6/7 - Additional Index Configurations"
Important: You need to update this JSON each time you make changes to the Synonym Sets otherwise you'll restore an older configuration.
Save
Reindex
Actual Result : Previously added Synonym Sets are preserved. You can see them on the Synonym Sets UI.
Backup and migrate existing Synonym sets - Multiple company (Virtual Instances)
Get the "analysis" settings from the index settings of each of your companies from the Elasticsearch server by following step 1) from the previous section
Perform a full reindex from the Search admin
Reindex spell check dictionaries too
Restore the analysis settings you obtained in step 1) for each company index by using the Update index settings API:
Go to Control Panel - Search Tuning - Synonyms and verify that the Synonym sets are there.
Tested on:
Tomcat 9.0.17 + MySQL 5.7
Portal master-private SHA: f7dd6670d1fb4f84519e9c1fd0e768348fffb990
Portal 7.2.x-private SHA: df31a3432ceeace3ca7f43189e72b5fc45625fd2