高亮无法显示,郁闷
来源:5-8 使用yii2-elasticsearch组件将ES集成到Yii2当中完成商品检索(1)

锋君
2017-08-15
[root@localhost ~] #5> curl -XPOST "http://192.168.19.130:9200/haiwei/products/_search?pretty" -d"@search.json" { "took" : 9, "timed_out" : false, "_shards" : { "total" : 5, "successful" : 5, "failed" : 0 }, "hits" : { "total" : 1, "max_score" : 0.014065012, "hits" : [ { "_index" : "haiwei", "_type" : "products", "_id" : "2", "_score" : 0.014065012, "_source" : { "productid" : 3, "title" : "?是一个水果标题", "descr" : "?是一个水果的描述" }, "highlight" : { "descr" : [ "?是一个水<em style=\"color:red;\">果</em>的描述" ], "title" : [ "?是一个水<em style=\"color:red;\">果</em>标题" ] } } ] } }
$highlight = [ "pre_tags" => ["<em style=\"color:red;\">"], "post_tags" => ["</em>"], "fields" => [ "title" => [], "descr" => [] ] ]; $res = Search::find()->query([ "multi_match"=>[ "query"=>"商品", "fields"=>["title","descr"] ] ])->highlight($highlight)->all();
写回答
1回答
-
锋君
提问者
2017-08-15
可以了,不知道哪里
012017-08-17
相似问题