作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的SQL查询中有一个WHERE子句,必须将其转换为elasticsearch bool过滤器。
这是where子句:
WHERE (
option = "weight" AND value = "50kg"
)
OR (
option = "weight" AND value = "500kg"
)
AND (
option = "magic" AND value = "no"
)
$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/
我是一名优秀的程序员,十分优秀!