您好,欢迎访问一九零五行业门户网

用elasticsearch-php laravel为什么不能返回高亮数据?

namespace app\http\controllers\search; use illuminate\http\request; use app\http\requests; use app\http\controllers\controller; use elasticsearch\client;class index extends controller{ protected $client; public function __construct(client $client) { $this->client = $client; } public function search_test(request $request,$filter='list'){ $word = trim($request->input('word')); $s=is_null($request->input('s'))?10:trim($request->input('s'));//一页多少条 $f=is_null($request->input('f'))?1:trim($request->input('f'));//当前页数 $fr=($f-1)*$s;//当前页从第一条记录开始 $params=[ 'index' => 's_index', 'type' => 's_type', 'body' => [ 'query' => [ 'bool' => [ 'should' => [ [ 'match' => [ 'title' => $word ] ], [ 'match' => [ 'description' => $word ] ], ] ] ] ,'from'=>$fr, 'size'=>$s ,'highlight'=>[ 'fields'=>[ 'title'=>[] ] ] ] ]; $response = $this->client->search($params); echo ; var_dump($response); echo

; } } 查询结果都能返回,就是无highlight数据,求朋友帮忙!!!
回复内容: namespace app\http\controllers\search; use illuminate\http\request; use app\http\requests; use app\http\controllers\controller; use elasticsearch\client;class index extends controller{ protected $client; public function __construct(client $client) { $this->client = $client; } public function search_test(request $request,$filter='list'){ $word = trim($request->input('word')); $s=is_null($request->input('s'))?10:trim($request->input('s'));//一页多少条 $f=is_null($request->input('f'))?1:trim($request->input('f'));//当前页数 $fr=($f-1)*$s;//当前页从第一条记录开始 $params=[ 'index' => 's_index', 'type' => 's_type', 'body' => [ 'query' => [ 'bool' => [ 'should' => [ [ 'match' => [ 'title' => $word ] ], [ 'match' => [ 'description' => $word ] ], ] ] ] ,'from'=>$fr, 'size'=>$s ,'highlight'=>[ 'fields'=>[ 'title'=>[] ] ] ] ]; $response = $this->client->search($params); echo ; var_dump($response); echo

; } } 查询结果都能返回,就是无highlight数据,求朋友帮忙!!!
暂时没做过搜索服务,感觉高亮的数据应该在控制器里面处理的吧。
其它类似信息

推荐信息