Skip to content

Elasticsearch search engine

Elasticsearch is an open-source, distributed, Java-based search engine that responds to queries in real-time and is scalable in reaction to changing processing needs.

Elasticsearch enables you to use filtering, query, query-time boosting, full-text search, and aggregations. It organizes data into documents, that then are grouped into indices.

As a result of having distributed architecture, Elasticsearch can analyze massive amounts of data with almost real-time performance. Instead of searching text directly, it searches and index. Thanks to this mechanism, it's able to achieve fast response.

For a detailed description of advanced settings that you might require in a specific production environment, see the documentation provided by Elastic. Start with the Set up Elasticsearch section.

Prerequisite

To proceed you need to be familiar with how indexing, filtering and queries work.

Update Elasticsearch schema

Whenever you make any changes in case of variables (for example, environmental ones) or configuration files, you need to erase Elasticsearch index, update the schema, and rebuild the index.

To delete an index, you can use the Elasticsearch's REST API.

First, use the _cat/indices endpoint to list existing indices. For example, the command curl -H "Accept: application/text" elasticsearch:9200/_cat/indices returns output like the following:

1
2
3
4
5
6
7
yellow open default_location_eng_gb_54 DoSFV-CtQFylKKVvd48YfA 1 1  1 0 16.7kb 16.7kb
yellow open default_location_eng_gb_42 3Z_IrWVHQh2m37jPqQBOcQ 1 1  1 0 20.1kb 20.1kb
yellow open default_content_eng_gb_45  y-t4uNQwR4KRJ-N9i3zUog 1 1  1 0 21.3kb 21.3kb
yellow open default_content_eng_gb_46  e_LS5qG3RIih6iQRPsNp-w 1 1  1 0 22.5kb 22.5kb
yellow open default_content_eng_gb_1   101-1-tQS_2KSvNs2X2JAQ 1 1 17 0 39.8kb 39.8kb
yellow open default_location_eng_gb_46 fSGtpljwTpGfascFechmww 1 1  1 0   21kb   21kb
(...)

Create a list containing all indices used by the DXP, including the custom indices as well.

Then, delete them by using the delete index endpoint

1
2
3
curl --request DELETE 'https://elasticsearch:9200/default_location*'
curl --request DELETE 'https://elasticsearch:9200/default_content*'
(...)

Tip

To quickly delete all existing Elasticsearch indices, you can use the _all keyword as the name of the index, as in the following request: curl --request DELETE https://elasticsearch:9200/_all. Always review the list of existing indices and confirm they are safe to delete before executing this command, as it permanently removes data.

To update the schema and then reindex the search, use the following commands:

1
2
php bin/console ibexa:elasticsearch:put-index-template --overwrite
php bin/console ibexa:reindex