文章目录
multi search template API允许使用_msearch/template在同一API中执行多个search template请求。
格式一般是
header\n
body\n
header\n
body\n
header 部分可以有 index, search_type, preference, and routing
body 是一个search_template请求,可以使用inline template,也可以使用stored的template
$ cat requests
{"index": "test"}
{"source": {"query": {"match": {"user" : "{{username}}" }}}, "params": {"username": "john"}}
{"source": {"query": {"{{query_type}}": {"name": "{{name}}" }}}, "params": {"query_type": "match_phrase_prefix", "name": "Smith"}}
{"index": "_all"}
{"id": "template_1", "params": {"query_string": "search for these words" }}
$ curl -H "Content-Type: application/x-ndjson" -XGET localhost:9200/_msearch/template --data-binary "@requests"; echo