Request Body Search
搜索请求能够通过DSL来执行,在请求体中包含这个查询DSL即可。下面是一个示例:
这是一个示例的响应:
参数
在上述中,search_type
和request_cache
必须作为查询字符串参数传递。搜索请求的其余部分应在主体本身内传递。请求体内容也可以作为名为source
的REST参数传递。
HTTP GET
和HTTP POST
都可以用来执行与body
的搜索。由于并非所有客户端都支持GET
,所以POST
也是允许的。
速检查任何匹配的文档
如果我们只想知道是否有匹配特定查询的文档,我们可以将大小设置为0
,表示我们对搜索结果不感兴趣。此外,我们可以将terminate_after
设置为1
,以指示每当找到第一个匹配文档(每个分片)时,查询执行可以被终止。
响应不会包含大小设置为0
的任何采样。hits.total
等于0
表示没有匹配的文档,或大于0
表示至少有与查询匹配的数量的文档(当它被提前终止时)。此外,如果查询提前终止,则在响应中将terminate_early
标志设置为true
。
Last updated