Elasticsearch - gquintana/beepbeep GitHub Wiki
Elasticsearch
Scripts
Scripts use the Sense / Kibana Console syntax
# Create index
PUT book
{
"settings": {
"number_of_shards": 3
}
}
# Put data
PUT book/book/1
{
"title": "Elasticsearch in action"
}
Command line
$ bin/beepbeep.sh -t elasticsearch -d http://localhost:9200 -s .beepbeep/script -f 'script/*.json'
http://localhost:9200/
: URL where is located the Elasticsearch server (or HTTP load balancer).beepbeep/script
: Index name and type name used to store ran script and not execute them twicescript/*.json
: File glob to select which scripts should be ran. File system is scanned. Scripts are ran in lexical order.
$ bin/beepbeep.sh -c config/elasticsearch.yml
elasticsearch.yml
: Configuration file containing all the settings (see below)
Java API
This API can be used on Java application startup or unit test startup
ElasticsearchPipelineBuilder pipelineBuilder = new ElasticsearchPipelineBuilder()
.withUrl("http://localhost:9200")
.withHttpClientProvider(new HttpClientProvider())
.withScriptStore(".beepbeep/script")
.withVariable("replicas", 1)
.withResourcesScriptScanner(Thread.currentThread().getContextClassLoader(), "script/*.json");
pipelineBuilder.scan();
HttpClientProvider
: allows to tune how Apache HTTP Client connects to ElasticsearchUrl
: URL where is located the Elasticsearch server (or HTTP load balancer)ScriptStore
: Index name and type name used to store ran script and not execute them twiceResourcesScriptScanner
: File glob to select which scripts should be ran. Classpath is scanned. Scripts are ran in lexical order.Variable
: will replace the string${replicas}
by1
before executing the query.
Configuration file
The optional configuration file
---
type: elasticsearch
charset: UTF-8
url: http://localhost:9200
scriptStore: beepbeep/script
scripts:
- script/**/*.json
variables:
replicas: 2
Shield
$ export JAVA_OPTS="-Djavax.net.ssl.trustStore=config/truststore.jks -Djavax.net.ssl.trustStorePassword=ts_password"
$ bin/beepbeep.sh -t elasticsearch -d https://localhost:9200 -u username -p password -s .beepbeep/script -f 'script/*.json'
username
andpassword
will be used for HTTP basic authentication.JAVA_OPTS=-Djavax.net.ssl.trustStore=truststore.jks
: useJAVA_OPTS
environment variable to add Java settings for SSL. Thetruststore.jks
contains the trusted certificate chain used for HTTPS.