0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

JuliaでElasticsearchにリクエストを送る

Posted at

ローカルに立てたElasticsearchにリクエストしている
サーバーを立てた場合はドメインを適切に変更する

using HTTP
using JSON

# ESの情報を取得する
HTTP.request("GET", "http://loccalhost:9200")

# indexを作成する
HTTP.request("PUT", "http://localhost:9200/julia_test")

# ドキュメントを登録する
create_param = Data(:last_name => "last_name", :first_name => "first_name", :age => 20)
HTTP.request("POST", "http://localhost:9200/julia_test/_doc", ["Content-Type" => "application/json"], JSON.json(create_param))

# IDで検索する
HTTP.request("GET", "http://localhost:9200/julia_test/_doc/aabb12345")

# 全件取得
HTTP.request("GET", "http://localhost:9200/julia_test/_search")

# 条件を指定して検索
search_param = Dict(:query => Dict(:match => Dict(:first_name => "first_name")))
HTTP.request("GET", "http://localhost:9200/julia_test/_search", ["Content-Type" => "application/json"], JSON.json(search_param))

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?