【发布时间】:2018-01-28 23:44:24
【问题描述】:
我想用一个请求在 elasticsearch 服务器上执行多个查询。具体来说,我有以下查询(在 elastcisearch-php-client 上)
$params = [
"index" => "bookydate",
"type" => "vendor_service",
"body" => [
"query" => [
"bool" => [
"must" => [
"term" => [
"sys_service_id" => $request->input("sys_service_id")
]
],
"should" => [
"geo_shape" => [
"served_location" => [
"shape" => [
"type" => "point",
"coordinates" => [
"{$request->input('loc_lon')}",
"{$request->input('loc_lat')}"]
]
]
]
]
]
]
]
];
我想要做的是将所有具有"hole_country" 字段的文档也提取到true。
我已经尝试过向 Elasticsearch 服务器发出另一个请求,并使用 array_merge 组合这两个结果,但由于 PHP 对具有多个相同键的数组的限制而没有工作。
更新
Elastcisearch 支持一个名为Multisearch 的功能,这正是我想要的。问题是 php-client 不支持多搜索,所以我必须使用 Guzzle 来发送请求。
Guzzle 文档没有关于如何构建正确请求正文的完整信息。欢迎提供任何信息
我已经有以下正文,但 elastcisearch 正在返回错误请求错误
$body = [
["index"=>"bookydate"],
["query"=>["bool"=> ["must"=>[["term"=>["sys_service_id"=>"1"]],["geo_shape"=>["served_location"=>["shape"=>["type"=>"circle","coordinates"=>[25,3],"radius"=>"90km"]]]]]]]],
["index"=>"bookydate"],
["query"=>["bool"=>["must"=>["term"=>["hole_country"=>true]]]]]
];
【问题讨论】:
标签: php elasticsearch