gpt4 book ai didi

php - 在一个请求中合并两个查询

转载 作者:行者123 更新时间:2023-12-02 22:58:36 26 4
gpt4 key购买 nike

我想通过一个请求在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客户端不支持多重搜索,因此我必须使用Guzzle才能发送请求。

Guzzle docs没有有关如何构造正确的请求正文的完整信息。欢迎任何信息

我已经具有以下主体,但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]]]]]
];

最佳答案

您可以使用Elasticsearch的multisearch API。这或多或少在单个POST请求中将所有查询作为JSON格式追加。我希望PHP客户端支持此功能,否则您可能必须手动执行POST请求。

Multi-search API

关于php - 在一个请求中合并两个查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42317507/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com