项目作者: techjacker

项目描述 :
Runs queries against AWS elasticsearch deployments
高级语言: Python
项目地址: git://github.com/techjacker/elasticsearchquery.git
创建时间: 2018-06-03T17:16:46Z
项目社区:https://github.com/techjacker/elasticsearchquery

开源协议:

下载


Build Status

AWS Elasticsearch Query

This library will run your static queries against elasticsearch deployments on AWS. Supply the endpoint plus the local filepath to your JSON file containing the query payload.

Good for lambda functions setting up mappings for AWS elasticsearch deployments.


Example Usage

Command Line

1. Set required environment variables

  1. # .env
  2. export ES_ENDPOINT=https://xxx.xxx.es.amazonaws.com
  3. export ES_REGION=eu-west-1
  1. $ source .env

2. Create JSON file with your Elasticsearch query to be run

  1. # my_es_query.json
  2. {
  3. "query": {
  4. "match": {
  5. }
  6. }
  7. }

3. Run your query

It will automatically pick up your AWS credentials from your shell’s environment.

  1. $ elasticsearchquery <es_index> <query_filepath>
  2. $ elasticsearchquery places my_es_query.json

Programmatic API

  1. from elasticsearchquery import ElasticSearchQuery
  2. esQuery = ElasticSearchQuery(
  3. es_endpoint='https://xxx.xxx.es.amazonaws.com',
  4. index_name='my_index',
  5. query_file='path_to_query.json',
  6. region='eu-west-1',
  7. )
  8. esQuery.run()

Unit Tests

1. Set Environment

Make a virtual environment and intall the dependencies.

  1. $ make env
  2. $ source env/bin/activate
  3. $ make deps

2. Run Unit Tests

  1. $ make test