0.1.0 • Published 6 years ago

gatsby-source-elasticsearch v0.1.0

Weekly downloads
11
License
MIT
Repository
github
Last release
6 years ago

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

OptionDescriptionType
connectionConnection detailsstring, object
indexThe index to query againststring
typeNameThe type name to generate in Gatsbystring
queryThe query to runstring, 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.