# Elastic Search Configuration

[Elastic Search](https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html) in ProcessMaker IDP provides enhanced search capabilities, including full-text search, structured search, and real-time analytics. Elastic search has the following key features:

* **Full-Text Search**: Perform comprehensive text searches across all indexed data.
* **Structured Search**: Use advanced queries with specific filters and parameters to refine search results.
* **Real-Time Analytics**: Access real-time insights and analytics based on search queries and data patterns

## **Setup and Configuration**

1. Go to **Admin Panel > Plugins > Elastic Search**.&#x20;
2. Enable the Elastic Search plugin.&#x20;
3. Enter the Elastic Search URL in the **Configuration** tab and save the settings.

***

## **Basic Requirements**

Setting up an Elastic Search index in ProcessMaker IDP has the following requirements

1. **Entities**: Define entities you want to index (e.g., FILE, PURCHASE\_ORDER).
2. **Index**: Create an index with the following configuration
   * A template.
   * An index mapping.
   * Field mappings with properties.
   * Query fields.
   * Aggregation to filter search results.&#x20;
3. **Process Mapping**: Run Process Mapping to send the Elastic Search configuration (index settings/mappings/templates) to the Elastic Search server.

***

## **Index**

An index defines how an entity's data is structured and made searchable within the system. You can configure an index to specifically suit your business needs.

**Indexing Data**:

* **Automatic Indexing**: Data within ProcessMaker IDP is automatically indexed when the Elastic Search plugin is enabled.
* **Manual Indexing**: Administrators can manually trigger indexing by navigating to **Admin Panel > Plugins > Elastic Search > Reindex**.

### **Create an Index**

Follow these steps to create an index:

1. Go to **Search > Indices > Create new Elastic Search Index**. The **Create index** screen will be displayed.
2. In **Setting Name**, Enter the name of the index. For example: <mark style="background-color:purple;">`index.number_of_shards`</mark> or <mark style="background-color:purple;">`index.number_of_replicas.`</mark>\
   \
   See the following links for more information:
   * [Elastic Search Index Modules](https://www.elastic.co/guide/en/elasticsearch/reference/current/index-modules.html)
   * [Elastic Search Create Index API](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html)
3. In **Setting Value**, enter a string value. For example: <mark style="background-color:purple;">`two`</mark> or <mark style="background-color:purple;">`2`</mark>.
4. Specify an entity from the Datastore schema which you want to make searchable.
5. Specify an attribute from the Entity Reference to configure a script/label per index. This determines what should be shown in the grid and list view of the search results.&#x20;
6. When an index is created, its state will be `NOT_PROCESSED`. After processing the index, the state will be `ACTIVE`. Only indices with the status `ACTIVE` are used for search.

{% hint style="warning" %}
**Update an Index**

It is possible to update in index in ProcessMaker IDP, however in Elastic Search, a new index will be created, and the old one will continue to exist.

**Delete an Index**

It is not possible to delete an index from ProcessMaker IDP. To delete an index from Elastic Search, see Use the [Elastic Search Delete Index API](https://www.elastic.co/guide/en/elasticsearch/reference/8.14/indices-delete-index.html).
{% endhint %}

***

## Index Mappings

A mapping defines how a document and its fields are stored and indexed.

### **Create a Mapping**

Follow these steps to create a mapping for your index:

1. Navigate to **YOUR\_INDEX > Edit > Mappings > Create new ElasticSearch Mapping**. The **Create mapping** screen will be displayed.
2. In the **Mapping Name** setting, entera  string identifying the mapping. This is sed to establish relations with other Elastic Search components, such as Mapping Properties, Mapping Dynamic Templates, etc. For more information, see:
   * [Mappings in Elastic Search](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping.html).
   * [Elastic Search index mapping](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html#mappings).
3. Optionally, in the **Dynamic Date Format** setting, enter a date format for this index. For more information, see [Elastic Search Dynamic Field Mapping](https://www.elastic.co/guide/en/elasticsearch/reference/current/dynamic-field-mapping.html#date-detection).

### **Mapping Properties**

* **Attribute Reference**: Specify an attribute from the Datastore schema that you want to make searchable.
* **ES Field Mapping Name**: Specify the relation to Field Mapping, which stores fine-grained Elastic Search specific settings:
  * **Field Datatype**: See [Elastic Search - Field Data Type.](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-types.html)
  * **Other Mapping Parameters**: See [Elastic Search - Mapping Parameters.](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-params.html)
* **Mapping Property Name**: Enter the same name as the Elastic Search Field Mapping Name.
* **Mapping Name**: Enter the mapping name to which the property belongs.
* **Parent Property**: Enter a reference to the parent mapping property used in multi-field mapping. For more details, see [Elastic Search - Multi-fields](https://www.elastic.co/guide/en/elasticsearch/reference/current/multi-fields.html). \
  \&#xNAN;***Note:*** If you define a parent mapping property, do not define an attribute or entity reference.

{% hint style="warning" %}
**Troubleshooting**

* **Connection Issues**: Ensure the Elastic Search server is active and the URL is correctly configured.
* **Indexing Problems**: Review logs for errors and ensure that data formats are correct.
* **Performance Tuning**: Optimize settings for memory allocation and query performance to enhance search efficiency.
  {% endhint %}

{% hint style="success" %}
**Best Practices**

* **Regular Monitoring**: Keep track of Elastic Search performance and health metrics.
* **Security**: Implement measures to protect Elastic Search from unauthorized access.
* **Backup**: Regularly back up Elastic Search indices to avoid data loss..
  {% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://processmaker.gitbook.io/idp/idp-administrator/elastic-search-configuration.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
