UNPKG

@ocap/indexdb-elasticsearch

Version:
46 lines (34 loc) 1.11 kB
# [**@ocap/indexdb-elasticsearch**](https://github.com/arcblock/blockchain) [![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier) > OCAP indexdb adapter that stores data in elasticsearch ## Install ```sh npm install @ocap/indexdb-elasticsearch // or pnpm install @ocap/indexdb-elasticsearch ``` ## Usage ```js const ESIndexDB = require('@ocap/indexdb-elasticsearch'); const indexdb = new ESIndexDB({ tokenLength: 28, endpoint: process.env.ES_ENDPOINT, auth: process.env.ES_USERNAME && process.env.ES_PASSWORD ? { username: process.env.ES_USERNAME, password: process.env.ES_PASSWORD, } : null, prefix: 'dev', requestTimeout: 30000, }); ``` **If you run this in production please set `ES_SHARD_COUNT` and `ES_REPLICA_COUNT` properly to achieve better reliability and performance** ## Run test Create a file: `indexdb/elasticsearch/.env.test`, and input: ```ini ES_ENDPOINT=<elasticsearch endpoint> ES_USERNAME=<elasticsearch username> ES_PASSWORD=<elasticsearch password> ```