FROM docker.elastic.co/elasticsearch/elasticsearch:6.2.4
# Plugin x-pack already exists in this image
# RUN elasticsearch-plugin install --batch x-pack
RUN elasticsearch-plugin install analysis-kuromoji
この Dockerfile に基づいてイメージをビルドする。
12345
> docker build -t es-kuromoji:1.0 ./
> docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
es-kuromoji 1.0 dxxxxxxxxxxx About a minute ago 519MB
...
> docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" es-kuromoji:1.0
起動を確認する。
123
> docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
xxxxxxxxxxxx es-kuromoji:1.0 "/usr/local/bin/dock…" About a minute ago Up Ab out a minute 0.0.0.0:9200->9200/tcp, 0.0.0.0:9300->9300/tcp sharp_hypatia
# In my environment, need `noproxy` option: curl http://localhost:9200/_cat/indices?v --noproxy localhost$ curl http://localhost:9200/_cat/indices?v
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
green open .monitoring-es-6-2018.06.07 xxxxxxxxxxxxxxxxxxxxxx 1 0 3094 2 1.1mb 1.1mb
# In windows, we can confirm Elasticsearch is running by using powershellPS C:\> Invoke-WebRequest -Uri http://localhost:9200/_cat/indices?v
StatusCode : 200
StatusDescription : OK
Content : health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
green open .monitoring-es-6-2018.06.07 xxxxxxxxxxxxxxxxxxxxxx 1 0 ...
RawContent : HTTP/1.1 200 OK
Content-Length: 246
Content-Type: text/plain; charset=UTF-8
health status index uuid pri rep docs.count docs.deleted store.size pri.store.s...
Forms : {}Headers : {[Content-Length, 246], [Content-Type, text/plain; charset=UTF-8]}Images : {}InputFields : {}Links : {}ParsedHtml : mshtml.HTMLDocumentClass
RawContentLength : 246
index を作ってみる。
index は RDB のテーブルやビューにあたる。
PUT メソッドを使って customer という index を作る。
pretty は JSON を pretty-print (pretty-print) してくれる。 jq みたいに整形してくれる。
$ curl http://localhost:9200/_cat/indices?v
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
green open .monitoring-es-6-2018.06.07 xxxxxxxxxxxxxxxxxxxxxx 1 0 4775 44 1.9mb 1.9mb
yellow open customer xxxxxxxxxxxxxxxxxxxxxx 5 1 0 0 1.1kb 1.1kb