예제 코드인 simple_basketball.json
을 넣어보자.
{ "index" : { "_index" : "basketball", "_type" : "record", "_id" : "1" } }
{"team" : "Chicago Bulls","name" : "Michael Jordan", "points" : 30,"rebounds" : 3,"assists" : 4, "submit_date" : "1996-10-11"}
{ "index" : { "_index" : "basketball", "_type" : "record", "_id" : "2" } }
{"team" : "Chicago Bulls","name" : "Michael Jordan","points" : 20,"rebounds" : 5,"assists" : 8, "submit_date" : "1996-10-11"}
이 파일로 index를 만들어보자
curl -XPOST -H "Content-Type: application/json" http://localhost:9200/_bulk?pretty --data-binary @simple_basketball.json
등록된 index 조회
curl -XGET http://localhost:9200/basketball/record/_search?pretty
Point가 30인 값만 검색하기
curl -XGET "http://localhost:9200/basketball/record/_search?q=points:30&pretty"
아래처럼 points가 30인 값만 검색되는 것을 확인할 수 있다.
쿼리문을 아래와 같이 전달 가능하다
curl -XGET -H "Content-Type: application/json" "localhost:9200/basketball/record/_search?pretty" -d'{"query":{"term":{"points":30}}}'