我尝试从搜索中获取突出显示,但结果没有突出显示。
我正在使用此插件:http://book.cakephp.org/3.0/en/elasticsearch.html#searching-indexed-documents
我的代码:
public function pesquisaIndice($searchText = null){
$this->loadModel('BooksI', 'Elastic');
$query = $this->BooksI->find()->limit(100)->highlight(['fields'=> ['number_of_fragments'=>20]]);
$query->where(function ($builder) {
return $builder->query(
[
'query_string' =>
[
'query'=> ' melhor',
'default_operator' =>'and'
],
]
);
});
var_dump($query);
}
答案 0 :(得分:0)
在命令行中我可以...但是使用这个插件我不能
curl -XGET "http://localhost:9200/my_apps_index/_search?pretty=true" -d '{
"query": {
"query_string": {
"query": "melhor"
}
},
"highlight": {
"pre_tags": ["<b>"],
"post_tags": ["</b>"],
"fields": {
"content": {"number_of_fragments": 20}
}
}
}'