码迷,mamicode.com
首页 > Web开发 > 详细

elasticksearch分词,导致kibana的url出现问题

时间:2017-06-23 14:12:12      阅读:375      评论:0      收藏:0      [点我收藏+]

标签:baidu   就会   需要   rds   tick   har   www   template   zed   

在Kibana的展示页面中,我们点击Table的左侧栏,发现Elasticsearch中的数据在展示中是正确的数据,比如:agent中www.baidu.com/test,该界面中会正确的显示为www.baidu.com/test,但是如果我们将该字段用Term展示出来的话,就会被分为www.baidu.com和test两组,通过查看CURL并没有发现其有任何问题,最后找到原因为Elasticsearch将其结果分开给了Kibana,所以Kibana会分开展示。
         通过研究,我们数据源为logstash自动收集过来的,索引是自动生成的,我们并不能去修改索引的Mapping将其设置为不分词,所以我们只能从其源头下手,当其创建的时候自动设置为不分词,这时我们就需要配置模板了。
代码如下:
curl -XPUT http://localhost:9200/_template/template_1 -d ‘ 
{
  "template" :"logstash*",
  "order" : 0,
  "settings" : {
    "number_of_shards" : 5
  },
  "mappings" : {
    "fluentd" : {
      "properties":{
          "request_dir" :{"type":"string","index" :"not_analyzed"},
          "http_user_agent" : {"type" : "string","index" :"not_analyzed" }
      }
    }
  }
}
‘

 

其中重要的是mappings 中的设置,一级一级的按照数据源正则分解,"index" : "not_analyzed"为不分词,便于搜索

elasticksearch分词,导致kibana的url出现问题

标签:baidu   就会   需要   rds   tick   har   www   template   zed   

原文地址:http://www.cnblogs.com/redheat/p/7069472.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!