Skip to main content
View plugin on GitHub
See starters using this

gatsby-source-elasticsearch

Gatsby source plugin for Elasticsearch.

This plugin uses the Elastisearch Scroll API to obtain any number of documents.

Installation

yarn add gatsby-source-elasticsearch

Options

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 to run string, object

Config Examples

Basic

module.exports = {
  plugins: [
    {
      resolve: 'gatsby-source-elasticsearch',
      options: {
        connection: 'http://localhost:9200',
        index: 'test-*',
        typeName: 'testDocs',
        query: 'type:test'
      },
    },
  ],
};

Advanced Connection Option

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',
        },
        // ...
      },
    },
  ],
};

Advanced Query Option

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.


Docs
Tutorials
Plugins
Blog
Showcase