可以使用msearch API获取文档计数吗?

huangapple go评论53阅读模式
英文:

Is it possible to get document count with msearch API?

问题

I'm using the /_msearch API to execute multiple queries with a single request.

But it does not allow me to specify the URL, so it looks like I can't get the document with /_count API.

Is there any way to get document count with msearch API?

英文:

I'm using the /_msearch API to execute multiple queries with a single request.

But it does not allow me to specify the URL, so it looks like I can't get the document with /_count API.

Is there any way to get document count with msearch API?

答案1

得分: 2

You can add another match_all query to your _msearch call, like this:

POST _msearch
{ "index": "index1" }
{ "query1" }
{ "index": "index2" }
{ "query2" }
{ "index": "index3" }
{ "track_total_hits": true, "size": 0, "query": {"match_all":{}} }

英文:

You can add another match_all query to your _msearch call, like this:

POST _msearch
{ "index": "index1" }
{ "query1" }
{ "index": "index2" }
{ "query2" }
{ "index": "index3" }
{ "track_total_hits": true, "size": 0, "query": {"match_all":{}} }

huangapple
  • 本文由 发表于 2023年5月17日 15:20:13
  • 转载请务必保留本文链接:https://go.coder-hub.com/76269465.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定