public function IgnoreCategoryQuery($category = 'main')
{
$categoriesTermQuery = new \Elastica\Query\Term();
$categoriesTermQuery->setTerm('categories', $category);
$categoriesBoolQuery = new \Elastica\Query\Bool();
$categoriesBoolQuery->addMustNot($categoriesTermQuery);
public function IgnoreCategoryQuery($category = 'main')
{
$categoriesTermQuery = new \Elastica\Query\Term();
$categoriesTermQuery->setTerm('categories', $category);
$categoriesBoolQuery = new \Elastica\Query\Bool();
$categoriesBoolQuery->addMustNot($categoriesTermQuery);
You should use the query DSL and not the more like this API. You can create
a boolean query where one clause is your more like this query and the other
one is your ignore category query (better use a filter here if you can).
However, more like this of the DSL only takes a like_text parameter, you
cannot pass the id of the document. This will change in a subsequent
version of ES. For now, to simulate this functionality, you can use
multiple mlt queries with a like_text set to the value of each field of the
queried document, inside a boolean query. Let me know if this helps.
Alex
On Wednesday, March 19, 2014 5:01:06 AM UTC+1, Alexey Bagryancev wrote:
Anyone can help me? It really does not work...
среда, 19 марта 2014 г., 2:05:49 UTC+7 пользователь Alexey Bagryancev
написал:
Hi,
I am trying to filter moreLikeThis results by adding additional query -
but it seems to ignore it at all.
I tried to run my ignoreQuery separately and it works fine, but how to
make it work with moreLikeThis? Please help me.
public function IgnoreCategoryQuery($category = 'main')
{
$categoriesTermQuery = new \Elastica\Query\Term();
$categoriesTermQuery->setTerm('categories', $category);
$categoriesBoolQuery = new \Elastica\Query\Bool();
$categoriesBoolQuery->addMustNot($categoriesTermQuery);
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.