> ## Documentation Index
> Fetch the complete documentation index at: https://docs.flowx.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# FlowX Data Search setup

> This guide will walk you through the process of setting up the Data Search service using a Docker image.

## Infrastructure prerequisites

Before proceeding, ensure the following components are set up:

* **Redis**
* **Kafka**
* **Elasticsearch**

## Dependencies

* **Kafka**: Used for communication with the engine
* **Elasticsearch**: Used for indexing and searching data
* **Redis**: Used for caching

## Configuration

### Kafka Configuration

Set the following Kafka-related configurations using environment variables:

* `SPRING_KAFKA_BOOTSTRAP_SERVERS`: Address of the Kafka server
* `KAFKA_TOPIC_DATA_SEARCH_IN`: The Kafka topic for the search service requests to the engine
* `KAFKA_TOPIC_DATA_SEARCH_OUT`: Where the engine awaits for the response
* `KAFKA_CONSUMER_THREADS`: Number of Kafka consumer threads

### Elasticsearch configuration

Configure Elasticsearch connection using the following environment variables:

| Variable                                  | Description                                 | Default Value      | Example              |
| ----------------------------------------- | ------------------------------------------- | ------------------ | -------------------- |
| `SPRING_ELASTICSEARCH_REST_URIS`          | URL(s) of Elasticsearch nodes (no protocol) | -                  | `elasticsearch:9200` |
| `SPRING_ELASTICSEARCH_REST_PROTOCOL`      | Connection protocol                         | `https`            | `https` or `http`    |
| `SPRING_ELASTICSEARCH_REST_DISABLESSL`    | Disable SSL verification                    | `false`            | `false`              |
| `SPRING_ELASTICSEARCH_REST_USERNAME`      | Authentication username                     | -                  | `elastic`            |
| `SPRING_ELASTICSEARCH_REST_PASSWORD`      | Authentication password                     | -                  | `your-password`      |
| `SPRING_ELASTICSEARCH_INDEXSETTINGS_NAME` | Index name for search data                  | `process_instance` | `process_instance`   |

### Authorization & access roles configuration

Set the following environment variables to connect to the identity management platform:

* `SECURITY_OAUTH2_BASE_SERVER_URL`
* `SECURITY_OAUTH2_CLIENT_CLIENT_ID`
* `SECURITY_OAUTH2_REALM`

### Logging configuration

Control log levels using these environment variables:

* `LOGGING_LEVEL_ROOT`: For root Spring Boot microservice logs
* `LOGGING_LEVEL_APP`: For app-level logs

### Elasticsearch

Data search in Elasticsearch operates against an index pattern representing multiple indices. The index pattern is derived from the configuration property `spring.elasticsearch.index-settings.name`.

Here's an example filter for use in Kibana (generated by data search):

```json theme={"system"}
{
  "query": {
    "bool": {
      "adjust_pure_negative": true,
      "boost": 1,
      "must": [
        {
          "nested": {
            "boost": 1,
            "ignore_unmapped": false,
            "path": "keyIdentifiers",
            "query": {
              "bool": {
                "adjust_pure_negative": true,
                "boost": 1,
                "must": [
                  {
                    "match": {
                      "keyIdentifiers.key.keyword": {
                        "auto_generate_synonyms_phrase_query": true,
                        "boost": 1,
                        "fuzzy_transpositions": true,
                        "lenient": false,
                        "max_expansions": 50,
                        "operator": "OR",
                        "prefix_length": 0,
                        "query": "astonishingAttribute",
                        "zero_terms_query": "NONE"
                      }
                    }
                  },
                  {
                    "match": {
                      "keyIdentifiers.originalValue.keyword": {
                        "auto_generate_synonyms_phrase_query": true,
                        "boost": 1,
                        "fuzzy_transpositions": true,
                        "lenient": false,
                        "max_expansions": 50,
                        "operator": "OR",
                        "prefix_length": 0,
                        "query": "OriginalGangsta",
                        "zero_terms_query": "NONE"
                      }
                    }
                  }
                ]
              }
            },
            "score_mode": "none"
          }
        },
        {
          "terms": {
            "boost": 1,
            "processDefinitionName.keyword": [
              "TEST_PORCESS_NAME_0",
              "TEST_PORCESS_NAME_1"
            ]
          }
        }
      ]
    }
  }
}
```

<Info>
  Kibana is an open-source data visualization and exploration tool designed primarily for Elasticsearch. It serves as the visualization layer for the Elastic Stack, allowing users to interact with their data stored in Elasticsearch to perform various activities such as querying, analyzing, and visualizing data.

  For more information about Kibana and its capabilities, visit the [**Kibana official documentation**](https://www.elastic.co/guide/en/kibana/current/index.html). This resource provides in-depth guidance, tutorials, and documentation on how to use Kibana effectively for data visualization, analysis, and dashboard creation.
</Info>
