我正在尝试将 mysql-query 转换为 Elasticsearch 的查询,但我认为我走错了路。
mysql 查询如下所示:
WHERE foo = 0 OR (foo = 1 AND bar LIKE "%blub%")
Elasticseach-query 的创建方式如下:
$fieldFoo = 'attributes.core.foo.raw';
$fieldBar = 'attributes.core.bar.raw';
$firstQuery = new BoolQuery();
$firstQuery->add(new TermQuery($fieldBar, "0"), BoolQuery::SHOULD);
$secondQuery = new BoolQuery();
$secondQuery->add(new WildcardQuery($fieldFoo, "*" . $value . "|*"));
$secondQuery->add(new TermQuery($fieldBar, "1"));
$firstQuery->add($secondQuery, BoolQuery::MUST);
$search->addQuery($query);
但这一个不起作用。接下来我可以尝试什么?