Enabling Search and Indexing for Guestbooks
Step 1 of 3
By default, Liferay DXP uses Elasticsearch, a search engine backed by the popular Lucene search library, to implement its search and indexing functionality. To avoid the resource-hogging table merges necessary to search the database, using a search engine like Elasticsearch lets you convert searchable entities into documents. In Elasticsearch, documents are searchable database entities converted into JSON objects. After you implement an indexer for guestbook entries, Liferay DXP creates a document for each entry. This indexer specifies which guestbook entry fields to add to each guestbook entry document. All the guestbook entry documents are then added to an index. When the index is searched, a hits object is returned that contains pointers to the documents matching the search query. Searching for entities with a search engine via an index is faster than searching for entities in the database. Elasticsearch provides some additional features like relevancy scoring and fuzzy search queries.
Along with the search engine, Liferay DXP has its own search infrastructure. Liferay DXP adds to the existing Elasticsearch API for a few reasons:
- To ensure indexed documents include the fields needed by Liferay DXP (e.g.,
groupId, staging status).
- To ensure the scope of returned search results is appropriate by applying the right filters to search requests.
- To provide permission checking and hit summaries to display in the search portlet.
Next, you’ll create the indexer for guestbooks.