How to build parent child relationship search in Elastic-search using Liferay API's?

472 Views Asked by At

We have a custom entity in Liferay called 'Publication'. It is indexed in Elastic-search and contains a field named 'journalArticleId'.

Based on our search requirements if some user searches for any keyword in the journal article we have to return the publication document which contains the 'journalArticleId' of the respective journal.

I found the solution for implementing this using Java API but I'm looking for the Liferay API to solve this.

Elastic Search Parent-Child Data Search Java API

Thanks in advance for any response.

3

There are 3 best solutions below

0
On BEST ANSWER

The elastic search provides features for parent-child mapping and the solution for the above situation can be implemented using Java API. Elastic Search Parent-Child Data Search Java API

We have contacted the Liferay support team and they responded that the Liferay-elasticsearch adapter doesn't support this feature yet. version : liferay-dxp-digital-enterprise-7.0-sp3

1
On

for the extension of existing indexers you should try to implement an indexer post processor hook ... instead of actually overriding them with an ext plugin

link for 6.2 https://dev.liferay.com/de/develop/tutorials/-/knowledge_base/6-2/extending-the-indexer-post-processor-using-a-hook

link for 7 aka dxp https://dev.liferay.com/de/develop/reference/-/knowledge_base/7-0/indexer-post-processor

2
On

You should be able to find documentation for overriding an indexer. It sounds like you could just extend the existing Journal Indexer: Just add the additional Publication data to the full text index for the existing Journal article and it will be found automatically.

Edit (after your comment): Without looking it up, I assume that Liferay's encapsulation of the API does not really cater for parent-child relationships (but: I might be wrong, it might be in or easy). However, Liferay also allows you to exchange Elasticsearch with SOLR (and potentially others) so its API naturally doesn't use all of the features of the underlying search engines. However, you should always be able to make the extra calls yourself - probably not in the indexer but closer to the ES adapter.

The solution might be: Prepare the content in the Indexer and separate it into parent and child later, in the Elasticsearch adapter.