【问题标题】:CakePHP 3 Return Highlights Elastic SearchCakePHP 3 返回亮点 Elastic Search
【发布时间】:2015-10-20 14:25:54
【问题描述】:

我尝试从我的搜索中获取 highlights,但结果没有 highlights

我正在使用这个插件: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);


 }

【问题讨论】:

    标签: cakephp elasticsearch cakephp-3.0 elasticsearch-plugin


    【解决方案1】:

    在命令行中我可以...但是使用这个插件我不能

    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}
            }
        }    
    }'
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-04-01
      • 1970-01-01
      • 2017-05-12
      • 1970-01-01
      • 2018-01-03
      • 2020-03-15
      • 1970-01-01
      相关资源
      最近更新 更多