由于大量的过滤条件(1000年代的许可系统),我必须使用Elastic_Query_Filtered
,它很不错,我甚至可以使用
$elasticaType->search($elasticaQueryString, $options);
直到我介绍了sort选项,这一切都很好。这是我到目前为止的内容:
$options = array('from'=>$from, 'size'=>$to, 'sort'=>array("description" => array("order" => "asc")));
$elasticaResultSet = $elasticaType->search($elasticaQueryString, $options);
我是在做一些愚蠢的事情,还是尚不支持排序?是否有其他选择。使用 bool(boolean) 过滤器使事情达到
max_clause_count
。 最佳答案
我用它来搜索单个查询字符串,包括限制和排序
$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 for where condition
$elasticaQueryString->setFields(array('increment_id','entity_id','billing_name')); // set where 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 from point
$elasticaQuery->setLimit(20); //limit the record
$sort = array("entity_id" => array("order" => "asc")); //order by clause
$elasticaQuery->setSort($sort); //set Sorting
echo "<br />".json_encode($elasticaQuery->toArray())."<br />"; //print the query
$search = new Elastica_Search($client); // Create the search object and inject the client
$resultSet = $search->addIndex('sales')->addType('order')->search($elasticaQuery); // Configure and execute the search
echo "<br /><strong>Total Results Found : ".$totalResults= $resultSet->getTotalHits()."</strong><br />"; //get total result found
$data=$resultSet->getResults(); //extract the result
$result=array();
foreach ($data as $data1)
{
$result[]=$data1->getData();
}
print_r($result);