[英]ongr-io elasticsearch bundle implementation with doctrine symfony2
[英]Add highlight using ongr-io/ElasticsearchDSL package
找不到任何示例如何使用https://github.com/ongr-io/ElasticsearchDSL向查詢結果添加亮點
<?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);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.