gpt4 book ai didi

sql - 如何将 “and or” where子句从sql查询转换为elasticsearch过滤器

转载 作者:行者123 更新时间:2023-12-03 02:07:09 25 4
gpt4 key购买 nike

我的SQL查询中有一个WHERE子句,必须将其转换为elasticsearch bool过滤器。

这是where子句:

WHERE (
option = "weight" AND value = "50kg"
)
OR (
option = "weight" AND value = "500kg"
)
AND (
option = "magic" AND value = "no"
)

我已经为查询的内部AND编写了AND过滤器,但是现在我需要将它们放入bool过滤器中。

试着:
$boolFilter = new \Elastica\Filter\Bool();
$boolFilter->addShould($innerFilterAnd1);
$boolFilter->addShould($innerFilterAnd2);
$boolFilter->addMust($innerFilterAnd3);

什么也不返回。

请帮忙!

最佳答案

谢谢“大家”,但是我自己想出了解决方案。
您可以使用以下要点测试案例:

GIST与我的搜索查询:
https://gist.github.com/ArFeRR/f69ebe24ddc543b7bffd

所以。如果要按嵌套对象进行过滤,则必须将其指定为“类型:对象”,而不是“类型:嵌套”。

因为这个:
http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/complex-core-fields.html#_arrays_of_inner_objects

(嵌套类型存储为数组,对象类型存储为对象)

关于sql - 如何将 “and or” where子句从sql查询转换为elasticsearch过滤器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24651542/

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