Symfony Nelmio Solarium Bundle FilterQuery
Symfony Nelmio Solarium Bundle FilterQuery
当我在solr中执行这段代码时API
....fq=title:(bionformatics OR scince)...
工作正常,return 数据适合过滤查询。
但是当我在 Solarium bundle 中尝试相同的查询时
$client = $this->solr->getClient();
$query = $client->createSelect();
$query->setFilterQueries('title:("bionformatics" OR "scince")');
我收到这个错误
Catchable Fatal Error: Argument 1 passed to
Solarium\QueryType\Select\Query\Query::addFilterQueries() must be of
the type array, string given, called in
/var/www/html/conference/vendor/solarium/solarium/library/Solarium/QueryType/Select/Query/Query.php
on line 737 and defined
我必须注意到 Solarium 捆绑包与
配合得很好
$query->setQuery('title:"bionformatics" OR title:"scince"');
错误消息准确地告诉您问题所在。
尝试:
$query->setFilterQueries(array('titleFilter' => 'title:("bioinformatics" OR "science")'));
或者因为您只想添加一个 Filterquery,请使用日光浴室文档中记录的方式 (http://solarium.readthedocs.io/en/stable/queries/select-query/building-a-select-query/adding-filterqueries/)
// get a select query instance
$query = $client->createSelect();
// create a filterquery
$query->createFilterQuery('maxprice')->setQuery('price:[1 TO 300]');
// this executes the query and returns the result
$resultset = $client->select($query);
当您查看此示例时,您也会清楚为什么 setFilterQueries 使用数组语法,因为每个过滤器查询都需要其唯一标识符。
当我在solr中执行这段代码时API
....fq=title:(bionformatics OR scince)...
工作正常,return 数据适合过滤查询。
但是当我在 Solarium bundle 中尝试相同的查询时
$client = $this->solr->getClient();
$query = $client->createSelect();
$query->setFilterQueries('title:("bionformatics" OR "scince")');
我收到这个错误
Catchable Fatal Error: Argument 1 passed to Solarium\QueryType\Select\Query\Query::addFilterQueries() must be of the type array, string given, called in /var/www/html/conference/vendor/solarium/solarium/library/Solarium/QueryType/Select/Query/Query.php on line 737 and defined
我必须注意到 Solarium 捆绑包与
配合得很好$query->setQuery('title:"bionformatics" OR title:"scince"');
错误消息准确地告诉您问题所在。
尝试:
$query->setFilterQueries(array('titleFilter' => 'title:("bioinformatics" OR "science")'));
或者因为您只想添加一个 Filterquery,请使用日光浴室文档中记录的方式 (http://solarium.readthedocs.io/en/stable/queries/select-query/building-a-select-query/adding-filterqueries/)
// get a select query instance
$query = $client->createSelect();
// create a filterquery
$query->createFilterQuery('maxprice')->setQuery('price:[1 TO 300]');
// this executes the query and returns the result
$resultset = $client->select($query);
当您查看此示例时,您也会清楚为什么 setFilterQueries 使用数组语法,因为每个过滤器查询都需要其唯一标识符。