I'm trying to convert an mysql-query to a query for Elasticsearch, but I think I am on the wrong way.
The mysql-query looks like the following:
WHERE foo = 0 OR (foo = 1 AND bar LIKE "%blub%")
The Elasticseach-query is created like the following:
$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);
But this one does not work. What can I try next?
The following solution works now: