Issue
In certain instances, an Elasticsearch node index might be improperly created, and documents appear to be successfully injected, but attempts to search for assets in the portal result in no findings.
Despite modifying the debug level in the com.liferay.portal.search packages, no errors are displayed, and Elasticsearch's log records the query without any issues.
This issue could be caused by an incorrect mapping for the related index in Elasticsearch.
Environment
- Liferay DXP 7.0
- Liferay DXP 7.1
- Liferay DXP 7.2
- Liferay DXP 7.3
- Liferay DXP 7.4
- Quarterly Release 2023.Q4
Resolution
It could be provoked by a wrong index mapping, in order to resolve this issue, follow these steps:
-
Verify the index mappings:
curl "http://${ip_elasticsearch}:9200/${prefix_index}-*/_mapping/LiferayDocumentType" - Check Elasticsearch if property action.auto_create_index is false, in order to avoid index creation automatically.
-
Delete erroneus index:
curl -X DELETE "${ip_elasticsearch}:9200/${index_name}?pretty" -
Force reindexing for the instance associated with the erroneous index with the following groovy script. (Note: replace 9999999 with the companyId of your instance)
/* Company to full reindex */
def companyId = 9999999;
def userId = java.lang.Long.parseLong(userInfo.get("liferay.user.id"));
com.liferay.portal.kernel.search.IndexWriterHelperUtil.reindex(userId, "reindex", [companyId] as long[], null); - Recheck the index mapping again. Now, you should be able to search for assets in that company
Additional Information
- https://www.elastic.co/guide/en/elasticsearch/reference/current/index-management-settings.html
- https://www.elastic.co/guide/en/elasticsearch/reference/7.17/docs-index_.html#index-creation