Why can't elasticsearch-phplaravel return highlighted data?

Source: Internet
Author: User
{Code...} returns all query results, that is, no highlight data. please help me !!!
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-> in Put ('s '))? 10: trim ($ request-> input ('s '); // how many records per page $ f = is_null ($ request-> input ('F '))? 1: trim ($ request-> input ('F'); // Current page $ fr = ($ F-1) * $ s; // the current page starts from the first record $ params = ['index' =>'s _ INDEX', 'type' =>'s _ type ', 'Body' => ['query' => ['Bool '=> ['shot' => [['match' => ['title' => $ word], ['match' => ['description' => $ word],], 'from' => $ fr, 'size' => $ s, 'highlight' => ['fields' => ['title' => []; $ response = $ this-> client-> search ($ params ); echo"
";        var_dump($response);        echo "
";}}

All query results can be returned, that is, there is no highlight data. please help !!!

Reply content:
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-> in Put ('s '))? 10: trim ($ request-> input ('s '); // how many records per page $ f = is_null ($ request-> input ('F '))? 1: trim ($ request-> input ('F'); // Current page $ fr = ($ F-1) * $ s; // the current page starts from the first record $ params = ['index' =>'s _ INDEX', 'type' =>'s _ type ', 'Body' => ['query' => ['Bool '=> ['shot' => [['match' => ['title' => $ word], ['match' => ['description' => $ word],], 'from' => $ fr, 'size' => $ s, 'highlight' => ['fields' => ['title' => []; $ response = $ this-> client-> search ($ params ); echo"
";        var_dump($response);        echo "
";}}

All query results can be returned, that is, there is no highlight data. please help !!!

I haven't done any search service yet. I feel like the highlighted data should be processed in the controller.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.