Elasticsearch - search_type 作为主体参数

jak*_*sky 5 elasticsearch

我对将 search_type 指定为 body 参数有点犹豫。作为一个很好的查询参数,但在手册中没有找到单个示例,其中将其指定为查询参数。

POST /index/type/_search
{
 "search_type": {"query_then_fetch"}, 
 "explain": false,
     "query" : { 
         "query_string": {
            "default_field": "adress.city",
            "query": "London"
         }
     }
}
Run Code Online (Sandbox Code Playgroud)

任何提示?

谢谢

Oll*_*ank 5

不支持将搜索类型放在正文中,来自文档

可以通过在查询字符串中设置 search_type 参数来配置类型。

所以你的查询应该是这样的:

curl -XGET http://localhost:9200/index/type/_search?search_type=query_then_fetch -d '
{
 "explain": false,
     "query" : { 
         "query_string": {
            "default_field": "adress.city",
            "query": "London"
         }
     }
}'
Run Code Online (Sandbox Code Playgroud)