Gatsby source plugin for Elasticsearch.
This plugin uses the Elastisearch Scroll API to obtain any number of documents.
npm install gatsby-source-elasticsearchor
yarn add gatsby-source-elasticsearch| Option | Description | Type |
|---|---|---|
| connection | Connection details | string, object |
| index | The index to query against | string |
| typeName | The type name to generate in Gatsby | string |
| query | The query as query string to run | string, object |
| body | The query body to run | object |
| scrollDuration | Scroll duration (default: 30s) | string |
| scrollSize | Scroll size (default: 1000) | integer |
Fields query and body are mutually exclusive.
For more information on scrollDuration and scrollSize, check out the Scroll documentation. scrollDuration maps to the scroll parameter in the documentation, and scrollSize to size.
module.exports = {
plugins: [
{
resolve: 'gatsby-source-elasticsearch',
options: {
connection: 'http://localhost:9200',
index: 'test-*',
typeName: 'testDocs',
query: 'type:test'
},
},
],
};If you pass the connection option as an object, you can use Elasticsearch client configuration options.
module.exports = {
plugins: [
{
resolve: 'gatsby-source-elasticsearch',
options: {
connection: {
host: 'http://localhost:9200',
log: 'info',
},
// ...
},
},
],
};If you pass the query option as an object, you can build a normal Elasticsearch search query. Otherwise, when it is passed in as a string it uses Elasticsearch query strings
module.exports = {
plugins: [
{
resolve: 'gatsby-source-elasticsearch',
options: {
query: {
bool: {
filter: [
{ term: { test: 'this' } },
],
},
},
// ...
},
},
],
};NOTE: This plugin does not support aggregations.