Connect Elasticsearch Data
Let’s connect PromptQL to a Elasticsearch database.
Add the Elasticsearch connector
ddn connector init elasticsearch -iOptional 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:9200The 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 elasticsearchAdd 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 localCreate a Hasura DDN project to get PromptQL running, even if you are on local dev
ddn project initStart your supergraph locally
ddn run docker-startHead to your local DDN console
Run the following from your project’s directory:
ddn console --localTalk to your data
Ask any questions you wish about your Elasticsearch data!