ElasticSearch
This documentation describes the integration of MindsDB with ElasticSearch, a distributed, multitenant-capable full-text search engine with an HTTP web interface and schema-free JSON documents.. The integration allows MindsDB to access data from ElasticSearch and enhance ElasticSearch with AI capabilities.
Prerequisites
Before proceeding, ensure the following prerequisites are met:
- Install MindsDB locally via Docker or Docker Desktop.
- To connect ElasticSearch to MindsDB, install the required dependencies following this instruction.
- Install or ensure access to ElasticSearch.
Connection
Establish a connection to ElasticSearch from MindsDB by executing the following SQL command and providing its handler name as an engine.
The connection parameters include the following:
cloud_id
: The Cloud ID provided with the ElasticSearch deployment. Required only whenhosts
is not provided.hosts
: The ElasticSearch endpoint provided with the ElasticSearch deployment. Required only whencloud_id
is not provided.api_key
: The API key that you generated for the ElasticSearch deployment. Required only whenuser
andpassword
are not provided.user
andpassword
: The user and password used to authenticate. Required only whenapi_key
is not provided.
If you want to connect to the local instance of ElasticSearch, use the below statement:
Required connection parameters include the following (at least one of these parameters should be provided):
hosts
: The IP address and port where ElasticSearch is deployed.user
: The user used to autheticate access.password
: The password used to autheticate access.
Usage
Retrieve data from a specified index by providing the integration name and index name:
The above examples utilize elasticsearch_datasource
as the datasource name, which is defined in the CREATE DATABASE
command.
At the moment, the Elasticsearch SQL API has certain limitations that have an impact on the queries that can be issued via MindsDB. The most notable of these limitations are listed below:
- Only
SELECT
queries are supported at the moment. - Array fields are not supported.
- Nested fields cannot be queried directly. However, they can be accessed using the
.
operator.
For a detailed guide on the limitations of the Elasticsearch SQL API, refer to the official documentation.
Troubleshooting Guide
Database Connection Error
- Symptoms: Failure to connect MindsDB with the Elasticsearch server.
- Checklist:
- Make sure the Elasticsearch server is active.
- Confirm that server, cloud ID and credentials are correct.
- Ensure a stable network between MindsDB and Elasticsearch.
Transport Error
or Request Error
- Symptoms: Errors related to the issuing of unsupported queries to Elasticsearch.
- Checklist:
- Ensure the query is a
SELECT
query. - Avoid querying array fields.
- Access nested fields using the
.
operator. - Refer to the official documentation for more information if needed.
- Ensure the query is a
SQL statement cannot be parsed by mindsdb_sql
- Symptoms: SQL queries failing or not recognizing index names containing special characters.
- Checklist:
- Ensure table names with special characters are enclosed in backticks.
- Examples:
- Incorrect: SELECT * FROM integration.travel-data
- Incorrect: SELECT * FROM integration.‘travel-data’
- Correct: SELECT * FROM integration.`travel-data`
This troubleshooting guide provided by Elasticsearch might also be helpful.
Was this page helpful?