简介
对es来说,有两种基本的检索方式,一种是通过URI传递检索参数,另一种是通过request body检索。通过request body进行检索,可以在json结构中传递更多信息,同时增强了可读性。
内容
通过URI检索
GET /bank/_search?q=*&sort=account_number:asc&pretty
说明:上面将搜索出bank中所有的document,其中q=*将会匹配在index中的所有的document,sort=account_number:asc表示使用account_number排序。如果直接使用GET /bank/_search默认也可以将全部document进行检索。搜索的结果如下:
{
"took": 27,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 3,
"relation": "eq"
},
"max_score": 1,
"hits": [
{
"_index": "test",