我通过为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?
答案 0 :(得分:0)
我还没完成你正在做的事情但我猜你需要使用\Elastica\Search
类,然后创建并发送一个查询。类似的东西:
$searcher = new \Elastica\Search( put-your-client-here! );
$esResultSet = $searcher->search($query);
$arrayOfResults = $esResultSet->getResults();
$arrayOfFacets = $esResultSet->getFacets();
祝你好运!