I've had to do this twice now, as I lost my info from the first time around. So, let's write it down...
First, let's run up elastic. Elastic give you info on how to do this on their site. I ended up firing a small docker compose:
version: '2'
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:7.2.0
container_name: elasticsearch
environment:
- cluster.name=docker-cluster
- discovery.type=single-node
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- esdata1:/usr/share/elasticsearch/data
ports:
- 9200:9200
volumes:
esdata1:
driver: local
You need to create your index (database...) before you can inject data into it:
#!/bin/bash
set -x
JSON_URL=192.168.0.111:9200/test1
curl -XPUT "$JSON_URL"
And then you can inject data into it:
#!/bin/bash
set -x
json=$(cat myfile.json)
JSON_URL=192.168.0.111:9200/test1/_doc
curl -XPOST -H"Content-Type: application/json" "$JSON_URL" -d "@-" <<< ${json}