0

我为 elastica 创建查询时遇到问题,它看起来像这样

$finder = $this->container->get('fos_elastica.finder.website.product');
$boolQuery = new \Elastica\Query\Bool();

$fieldText = new \Elastica\Query\Text();
$fieldText->setFieldQuery('name', $keyword);
$fieldText->setFieldParam('name', 'analyzer', 'my_analyzer');
$boolQuery->addMust($fieldText);//`enter code here

$fieldTerms = new \Elastica\Query\Terms();//`enter code here`enter code here`
$fieldTerms->setTerms('taxon_ids', $themeArray);//`enter code here`
$boolQuery->addMust($fieldTerms);


//But when I add Facets range it makes problem?Any Help?`enter code here`

 if(count($priceRange))
 {
 $facets = new \Elastica\Facet\Range('price');
 $facets->setField('price');
 $facets->addRange($min, $max);
 $facets->setGlobal(false);
 $query->addFacet($facets);
 }


 $resultSet = $finder->find($query, 500);///It brokes here?

请问有人可以帮我解决这个问题吗,我正在使用 FOSElasticaBundle?

4

1 回答 1

0

我还没有完全完成您正在做的事情,但我猜您需要使用\Elastica\Search该类,然后创建并向其发送查询。就像是:

$searcher = new \Elastica\Search( put-your-client-here! );

$esResultSet = $searcher->search($query);

$arrayOfResults = $esResultSet->getResults();
$arrayOfFacets =  $esResultSet->getFacets();

祝你好运!

于 2013-07-18T10:06:11.103 回答