ElasticSearch Search
xcurl -XGET localhost:9200/classes/class/_search?q=rating:5
출력결과
xxxxxxxxxx{"took":2,"timed_out":false,"_shards":{"total":5,"successful":5,"skipped":0,"failed":0},"hits":{"total":4,"max_score":1.0,"hits":[{"_index":"classes","_type":"class","_id":"19","_score":1.0,"_source":{"title" : "Cell Biology","Professor" : "Anjella Kim","major" : "Medical","semester" : ["fall"],"student_count" : 40,"unit" : 5,"rating" : 5, "submit_date" : "2016-02-22", "school_location" : {"lat" : 42.32, "lon" : -94.74}}},{"_index":"classes","_type":"class","_id":"12","_score":1.0,"_source":{"title" : "Vocal Techniques","Professor" : "Beyonce","major" : "Music","semester" : ["fall"],"student_count" : 30,"unit" : 3,"rating" : 5, "submit_date" : "2016-11-22", "school_location" : {"lat" : 42.51, "lon" : -74.83}}},{"_index":"classes","_type":"class","_id":"1","_score":1.0,"_source":{"title" : "Machine Learning","Professor" : "Minsuk Heo","major" : "Computer Science","semester" : ["spring", "fall"],"student_count" : 100,"unit" : 3,"rating" : 5, "submit_date" : "2016-01-02", "school_location" : {"lat" : 36.00, "lon" : -120.00}}},{"_index":"classes","_type":"class","_id":"11","_score":1.0,"_source":{"title" : "Music Fundamental","Professor" : "Jay Z","major" : "Music","semester" : ["fall"],"student_count" : 100,"unit" : 3,"rating" : 5, "submit_date" : "2016-05-22", "school_location" : {"lat" : 42.51, "lon" : -74.83}}}]}}
pretty를 넣어 출력하려 했는데 다르게 해야하는지 오류가 난다.
xxxxxxxxxxcurl -XGET localhost:9200/classes/class/_search?pretty -d "{ \"query\": { \"term\" : {\"rating\":5} } }" -H "Content-Type:application/json"이렇게 -d를 사용하여 위와 같은 검색을 할 수 있다.
rating값이 5인 것을 검색한 출력결과
xxxxxxxxxx{  "took" : 1,  "timed_out" : false,  "_shards" : {    "total" : 5,    "successful" : 5,    "skipped" : 0,    "failed" : 0  },  "hits" : {    "total" : 4,    "max_score" : 1.0,    "hits" : [      {        "_index" : "classes",        "_type" : "class",        "_id" : "19",        "_score" : 1.0,        "_source" : {          "title" : "Cell Biology",          "Professor" : "Anjella Kim",          "major" : "Medical",          "semester" : [            "fall"          ],          "student_count" : 40,          "unit" : 5,          "rating" : 5,          "submit_date" : "2016-02-22",          "school_location" : {            "lat" : 42.32,            "lon" : -94.74          }        }      },      {        "_index" : "classes",        "_type" : "class",        "_id" : "12",        "_score" : 1.0,        "_source" : {          "title" : "Vocal Techniques",          "Professor" : "Beyonce",          "major" : "Music",          "semester" : [            "fall"          ],          "student_count" : 30,          "unit" : 3,          "rating" : 5,          "submit_date" : "2016-11-22",          "school_location" : {            "lat" : 42.51,            "lon" : -74.83          }        }      },      {        "_index" : "classes",        "_type" : "class",        "_id" : "1",        "_score" : 1.0,        "_source" : {          "title" : "Machine Learning",          "Professor" : "Minsuk Heo",          "major" : "Computer Science",          "semester" : [            "spring",            "fall"          ],          "student_count" : 100,          "unit" : 3,          "rating" : 5,          "submit_date" : "2016-01-02",          "school_location" : {            "lat" : 36.0,            "lon" : -120.0          }        }      },      {        "_index" : "classes",        "_type" : "class",        "_id" : "11",        "_score" : 1.0,        "_source" : {          "title" : "Music Fundamental",          "Professor" : "Jay Z",          "major" : "Music",          "semester" : [            "fall"          ],          "student_count" : 100,          "unit" : 3,          "rating" : 5,          "submit_date" : "2016-05-22",          "school_location" : {            "lat" : 42.51,            "lon" : -74.83          }        }      }    ]  }}
ElasticSearch 공부하다가 막히는 부분 질문할 곳이 마땅히 없다는게 제일 어렵다
'Back-end' 카테고리의 다른 글
| Elastic Search - Bucket Aggregation (0) | 2018.09.01 | 
|---|---|
| Elastic Search -Metric Aggregation (0) | 2018.08.31 | 
| ElasticSearch Mapping (0) | 2018.08.30 | 
| Elastic Search 벌크 (0) | 2018.08.29 | 
| Elastic Search 자료구조 / GET POST PUT DELETE / UPDATE방법 (0) | 2018.08.29 | 
댓글