PHP通过API搜索elasticsearch只获得10条数据

时间:2022-03-18 20:58:56

PHP通过API对ES进行搜索后发现只能获取10条数据,搜索语句如下:

{   "query": {     "filtered": {       "query": {         "query_string": {           "query": "level:\"警告\" AND source_name:\"ASP.NET\" ",           "analyze_wildcard": true         }       },       "filter": {         "bool": {           "must": [             {               "range": {                 "@timestamp": {                   "gte": 1494309300,                   "lte": 1494489299,                   "format": "epoch_second"                 }               }             }           ],           "must_not": []         }       }     } } }

其余ES如果没有指定SIZE的话,,默认是10条

但是size也不能超过10000,否则也会报错。


修改搜索语句如下:

{   "size": 10000,   "query": {     "filtered": {       "query": {         "query_string": {           "query": "level:\"警告\" AND source_name:\"ASP.NET\" ",           "analyze_wildcard": true         }       },       "filter": {         "bool": {           "must": [             {               "range": {                 "@timestamp": {                   "gte": 1494309300,                   "lte": 1494489299,                   "format": "epoch_second"                 }               }             }           ],           "must_not": []         }       }     } } }

即可