DocsGuidesConnect Elasticsearch

Connect Elasticsearch Data

Let’s connect PromptQL to a Elasticsearch database.

Add the Elasticsearch connector

ddn connector init elasticsearch -i

Optional Check this repo for a docker-compose setup for Elasticsearch local instance.

Optional Load a sample dataset into Elasticsearch

npx create-elasticsearch-dataset --dataset=books
  • Select hasura/elasticsearch and accept the default port by pressing “return”.

You’ll need a Elasticsearch Connection String to connect to the database; it takes this form:

http://<host>:<port>
http://local.hasura.dev:9200

The CLI will also ask for the ELASTICSEARCH_USERNAME and ELASTICSEARCH_PASSWORD. Enter the relevant values.

Note: If you are using Elastic Cloud, you might also need to configure the ELASTICSEARCH_API_KEY.

Feel free to skip the remaining environment variables.

Introspect your data source

Introspect your data source to create a set of configuration files describing your data source in a format which the connector specifies.

ddn connector introspect elasticsearch

Add your resources

Add your resources to create metadata for models, commands, and relationships in your supergraph.

ddn model add elasticsearch "*"
ddn command add elasticsearch "*"
ddn relationship add elasticsearch "*"

Build your supergraph for the local engine

ddn supergraph build local

Create a Hasura DDN project to get PromptQL running, even if you are on local dev

ddn project init

Start your supergraph locally

ddn run docker-start

Head to your local DDN console

Run the following from your project’s directory:

ddn console --local

Talk to your data

Ask any questions you wish about your Elasticsearch data!