文章目录
感觉这个multi search API好像没有啥作用,就是可以同时发起好多search,但是使用的时候感觉作用不大
GET twitter/_msearch
{}
{"query" : {"match_all" : {}}, "from" : 0, "size" : 10}
{}
{"query" : {"match_all" : {}}}
{"index" : "twitter2"} # 这个是说明下面的search针对的是twitter2 这个index
{"query" : {"match_all" : {}}}
可以使用template
POST /_scripts/my_template_1
{
"script": {
"lang": "mustache",
"source": {
"query": {
"match": {
"message": "{{query_string}}"
}
}
}
}
}
POST /_scripts/my_template_2
{
"script": {
"lang": "mustache",
"source": {
"query": {
"term": {
"{{field}}": "{{value}}"
}
}
}
}
}
GET _msearch/template
{"index" : "main"}
{ "id": "my_template_1", "params": { "query_string": "some message" } }
{"index" : "main"}
{ "id": "my_template_2", "params": { "field": "user", "value": "test" } }