高亮无法显示,郁闷

来源: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

可以了,不知道哪里

0
1
Jason
恩,看起来像是中文分词的问题,有问题再来提问
2017-08-17
共1条回复

Yii2.0进阶版 高级组件ES/Redis/Sentry优化京东平台

进阶更高阶的Yii 2.0开发,获得2-3年yii 2.0实战经验

514 学习 · 210 问题

查看课程