/_msearch
方法:GET_routing
参数值来提高查询效率,具体请参照示例。也可通过设置 filter_path 参数来过滤并简化返回结果,其参数值为按照逗号分隔的多个 json 路径,其中单个 json 路径用点号连接,可以使用 *
通配符来适配任意字符, **
通配符可以用来匹配任意路径,可以使用 -
前缀来去除某些返回字段。responses._shard.f*
表示 responses
下 _shards
中的以 f 开头的字段; responses.**._score
表示 responses
中所有 _score
的字段。字段名称 | 描述 |
hits | 返回匹配的查询结果,其中 total 字段表示匹配到的数据条数。里面的 hits 字段为数组结构,若无指定,则包含所有查询结果的前十条。hits 数组里的每个结果中包含 _index(查询涉及到的 子表),若查询中指定了 docvalue_fields,则会返回 fields 字段具体指明每个字段的值。 |
took | 整个查询耗费的毫秒数。 |
_shards | 参与查询的分片数。其中 total 标识总分片数,successful 标识执行成功的数量,failed 标识执行失败的数量,skipped 标识跳过执行的分片数。 |
timed_out | 查询是否超时,取值有 false 和 true。 |
status | 查询返回的状态码,2XX 代表成功。 |
curl -u root:le201909 -H 'Content-Type:application/json' -X GET 172.xx.xx.4:9201/_msearch -d'{"index" : "amyli_weather","routing":"host_20"}{"query" : {"match_all" : {}}, "from" : 0, "size" : 10}{"index" : "ctsdb_test2017","routing":"host_100"}{"query" : {"match_all" : {}}, "from" : 0, "size" : 10}'
{"responses":[{"took": 0,"timed_out": false,"_shards": {"total": 0,"successful": 0,"skipped": 0,"failed": 0},"hits": {"total": 0,"max_score": 0,"hits": []},"status": 200},{"took": 1,"timed_out": false,"_shards": {"total": 3,"successful": 3,"skipped": 0,"failed": 0},"hits": {"total": 1,"max_score": 1,"hits": [{"_index": "ctsdb_test2017@-979200000_30","_type": "doc","_id": "AV_8fBhlUAkC9PF9L-2t","_score": 1}]},"status": 200}]}
curl -u root:le201909 -H 'Content-Type:application/json' -X GET 172.xx.xx.4:9201/_msearch?filter_path=responses.\\*\\*.hits,responses._shards.f\\*,-responses.\\*\\*._score -d'{"index" : "amyli_weather","routing":"host_20"}{"query" : {"match_all" : {}}, "from" : 0, "size" : 10}{"index" : "ctsdb_test2017","routing":"host_100"}{"query" : {"match_all" : {}}, "from" : 0, "size" : 10}'
{"responses": [{"_shards": {"failed": 0}},{"_shards": {"failed": 0},"hits": {"hits": [{"_index": "ctsdb_test2017@-979200000_30","_type": "doc","_id": "AV_8fBhlUAkC9PF9L-2t"}]}}]}
本页内容是否解决了您的问题?