if(count($priceRange)){
$facets = new \Elastica\Facet\Range('price');
$facets->setField('price');
foreach ($min as $key => $value) {
$facets->addRange(intval($min[$key])*100, intval($max[$key])*100);
}
$facets->setGlobal(false);
$query->addFacet($facets);
}
这对我不起作用,我试图在两个方面进行搜索。
像这样:
$client = $this->container->get('fos_elastica.client')
$searcher = new \Elastica\Search($client)
$esResultSet = $searcher->search($query , 500)
$arrayOfResults = $esResultSet->getResults()
$facets = $esResultSet->getFacets()
或者像这样
$resultSet = $finder->find($query, 500)
这两种方法都不奏效。为什么我的方面范围不起作用?
答案 0 :(得分:0)
这是更多代码:
$boolQuery = new \Elastica\Query\Bool();
$fieldText = new \Elastica\Query\Text();
$fieldText->setFieldQuery('name', $keyword);
$fieldText->setFieldParam('name', 'analyzer', 'my_analyzer');
$boolQuery->addMust($fieldText);
$fieldText = new \Elastica\Query\Text();
$fieldText->setFieldQuery('description', $keyword);
$fieldText->setFieldParam('description', 'analyzer', 'my_analyzer');
$boolQuery->addShould($fieldText);
$fieldTerms = new \Elastica\Query\Terms();
$fieldTerms->setTerms('country_id', $countryArray);
$boolQuery->addMust($fieldTerms);
$fieldTerms = new \Elastica\Query\Terms();
$fieldTerms->setTerms('taxon_ids', $themeArray);
$boolQuery->addMust($fieldTerms);
$query->setSort(array("price" => array("order" => "asc")));