php - Sorting the results from a Filtered Query -
due big amount of filter terms (permissions scheme in 1000s) have utilize elastic_query_filtered
fine , can set limits pagination using
$elasticatype->search($elasticaquerystring, $options);
it works quite until introduce sort option. here's have far:
$options = array('from'=>$from, 'size'=>$to, 'sort'=>array("description" => array("order" => "asc"))); $elasticaresultset = $elasticatype->search($elasticaquerystring, $options);
am doing stupid or sorting not supported yet. there alternative. using bool filter making things nail max_clause_count
.
i used search on single query string, limit , sorting
$client = new elastica_client(array('host' => '192.168.0.27','port' => '9200')); $elasticaquerystring =new elastica_query_querystring(); $elasticaquerystring->setdefaultoperator('and'); $elasticaquerystring->setquery('100009'); // set value status $elasticaquerystring->setfields(array('increment_id','entity_id','billing_name')); // set fields $elasticaquery = new elastica_query(); $elasticaquery->setquery($elasticaquerystring); // set query string $elasticaquery->setfields(array('increment_id','entity_id','billing_name','created_at')); // set output fields $elasticaquery->setfrom(0); //set point $elasticaquery->setlimit(20); //limit record $sort = array("entity_id" => array("order" => "asc")); //order clause $elasticaquery->setsort($sort); //set sorting echo "<br />".json_encode($elasticaquery->toarray())."<br />"; //print query $search = new elastica_search($client); // create search object , inject client $resultset = $search->addindex('sales')->addtype('order')->search($elasticaquery); // configure , execute search echo "<br /><strong>total results found : ".$totalresults= $resultset->gettotalhits()."</strong><br />"; //get total result found $data=$resultset->getresults(); //extract result $result=array(); foreach ($data $data1) { $result[]=$data1->getdata(); } print_r($result);
php elasticsearch elastica
No comments:
Post a Comment