Skip to content

Conversation

@Akiler520
Copy link

@Akiler520 Akiler520 commented Aug 22, 2018

return highlight to response

e.g.

    `$json = '{
            "query" : {
                    "match": { "name": "淳于理群" }
            },
            "highlight" : {
                "fields" : {
                    "name" : {}
                 }
            }
        }';
    $result = json_decode($json);

    $documents = ES::type('product_list')->body($result)->get();

    if ($documents){
        foreach ($documents as $document) {
            var_dump(json_encode($document->attributes));exit;
        }
    }

`

result:

    {
        "name":"淳于理群",
        "last_name":"",
        "age":57,
        "about":"淳于理群很喜欢足球,喜欢看报纸,也喜欢游泳",
        "interests":[
                "上网聊天",
                "滑雪"
            ],
        "_index":"product",
        "_type":"product_list",
        "_id":"06uFW2UB12PvfbBPiLfC",
        "_score":18.34602,
        "_highlight":{
                "name":[
                    "<em>淳</em><em>于</em><em>理</em><em>群</em>"
                ]
        }
    }

return highlight
@Akiler520 Akiler520 changed the title Update Query.php return highlight to response Aug 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant