0

I have problem by creating query for elastica,it looks like this

$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?

Please can anybody help me with this query, I am using FOSElasticaBundle?

1 Answers1

0

I haven't done exactly what you are doing BUT I would guess you need to use the \Elastica\Search class, then create and send a query to that. Something like:

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

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

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

Good luck!

ramseykhalaf
  • 3,371
  • 2
  • 17
  • 16