本文整理汇总了PHP中CSearch::normalizeEncoding方法的典型用法代码示例。如果您正苦于以下问题:PHP CSearch::normalizeEncoding方法的具体用法?PHP CSearch::normalizeEncoding怎么用?PHP CSearch::normalizeEncoding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSearch
的用法示例。
在下文中一共展示了CSearch::normalizeEncoding方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: searchQueryString
/**
* simple search with an operator and words
*
* @param string $operator 'And' or 'Or' default : 'Or'
* @param string $words data
* @param integer $start the begining of the paging
* @param integer $limit the interval of the paging
* @param array $names_types the restrictive type(s) where the search take place.
* @param bool $aggregation parameter the search to be aggregated or not.
*
* @return \Elastica\ResultSet
*/
function searchQueryString($operator, $words, $start = 0, $limit = 30, $names_types = null, $aggregation = false)
{
$words = CSearch::normalizeEncoding($words);
// Define a Query. We want a string query.
$queryString = new Elastica\Query\QueryString($words);
$queryString->setDefaultOperator("and");
// Create the actual search object with some data.
$query = new Elastica\Query($queryString);
//create aggregation
if ($aggregation) {
// on aggrège d'abord par class d'object référents
// on effectue un sous aggrégation par id des objets référents.
$agg_by_date = new CSearchAggregation("Terms", "date_log", "date", 10);
$sub_agg_by_user = new CSearchAggregation("Terms", "user_id", "user_id", 10);
$sub_agg_by_contexte = new CSearchAggregation("Terms", "contexte", "_type", 10);
$sub_agg_by_user->_aggregation->addAggregation($sub_agg_by_contexte->_aggregation);
$agg_by_date->_aggregation->addAggregation($sub_agg_by_user->_aggregation);
$query->addAggregation($agg_by_date->_aggregation);
} else {
// Pagination
$query->setFrom($start);
// Where to start
$query->setLimit($limit);
}
//Highlight
$query->setHighlight(array("fields" => array("body" => array("pre_tags" => array(" <em> <strong> "), "post_tags" => array(" </strong> </em>"), "fragment_size" => 80, "number_of_fragments" => 10))));
//Search on the index.
$index = CAppUI::conf("search index_name") . "_log";
$index = $this->loadIndex($index);
$search = new \Elastica\Search($this->_client);
$search->addIndex($index);
if ($names_types) {
$search->addTypes($names_types);
}
return $search->search($query);
}