@baymose/gatsby-source-elasticsearch

1.0.0 • Public • Published

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.

Package Sidebar

Install

npm i @baymose/gatsby-source-elasticsearch

Weekly Downloads

2

Version

1.0.0

License

MIT

Unpacked Size

94.9 kB

Total Files

12

Last publish

Collaborators

  • baymose