elasticsearch,ongr,Php,elasticsearch,Ongr" /> elasticsearch,ongr,Php,elasticsearch,Ongr" />

Php 使用ongr io/ElasticsearchDSL包添加突出显示

Php 使用ongr io/ElasticsearchDSL包添加突出显示,php,elasticsearch,ongr,Php,elasticsearch,Ongr,找不到如何使用添加到查询结果的任何示例 <?php require 'vendor/autoload.php'; //Composer autoload $client = ClientBuilder::create()->build(); //elasticsearch-php client $matchAll = new ONGR\ElasticsearchDSL\Query\MatchAllQuery(); $search = new ONGR\Ela

找不到如何使用添加到查询结果的任何示例


 <?php
  require 'vendor/autoload.php'; //Composer autoload

  $client = ClientBuilder::create()->build(); //elasticsearch-php client

  $matchAll = new ONGR\ElasticsearchDSL\Query\MatchAllQuery();

  $search = new ONGR\ElasticsearchDSL\Search();
  $search->addQuery($matchAll);

  //How to highlight results in title field?

  $params = [
    'index' => 'your_index',
    'body' => $search->toArray(),
  ];

  $results = $client->search($params);
 <?php
  require 'vendor/autoload.php'; //Composer autoload

  $client = ClientBuilder::create()->build(); //elasticsearch-php client

  $matchAll = new ONGR\ElasticsearchDSL\Query\MatchAllQuery();

  $search = new ONGR\ElasticsearchDSL\Search();
  $search->addQuery($matchAll);

  $higlight = new Highlight();
  $higlight->addField('title');
  $search->addHighlight($higlight);

  $params = [
    'index' => 'your_index',
    'body' => $search->toArray(),
  ];

  $results = $client->search($params);