由于线上elasticsearch集群数据量越来越大,优化已经已经是重中之重。

优化的方式有很多中,网上一大堆,自行百度。

优化方案中有个叫routing的方案是个需要熟悉业务日志才能使用。于是我就研究了routing方式。

网上有一大堆routing 的方法。但是大部分都是在mapping中加入_routing,required,path等参数工作的,但是我使用后发现有错误。如下:

reason": Mapping definition for [_routing] has unsupported parameters:  [path : category]"

查看官网后发现: 原来在es2.0之后就不支持这种方式了。

所以我通过这种方法:

logstash 中指定routing的字段,然后插入到es中,es中不做任何设置。

下面是我logstash的output部分:

  output {
  if [type] == "dsq-info" {
    elasticsearch {
    hosts => ["10.1.0.12:9200"]
    index => "%{[fields][index]}-%{+YYYY.MM.dd}"
    document_type => "%{[@metadata][type]}"
    routing => "%{category}"   ###这里是关键字,你选择使用那个字段做索引。
  }
  }
}

然后在kifana中指定routing查询。

GET ****/_search?routing=api      ###routing指定是字段中具体的值。

  

elasticsearch 自定义routing的更多相关文章

  1. elasticsearch 自定义_id

    elasticsearch 自定义ID: curl -s -XPUT localhost:9200/web -d ' { "mappings": { "blog" ...

  2. Elasticsearch 自定义多个分析器

    分析器(Analyzer) Elasticsearch 无论是内置分析器还是自定义分析器,都由三部分组成:字符过滤器(Character Filters).分词器(Tokenizer).词元过滤器(T ...

  3. Elasticsearch 自定义映射

    尽管在很多情况下基本域数据类型 已经够用,但你经常需要为单独域自定义映射 ,特别是字符串域.自定义映射允许你执行下面的操作: 全文字符串域和精确值字符串域的区别 使用特定语言分析器 优化域以适应部分匹 ...

  4. ElasticSearch自定义分析器-集成结巴分词插件

    关于结巴分词 ElasticSearch 插件: https://github.com/huaban/elasticsearch-analysis-jieba 该插件由huaban开发.支持Elast ...

  5. elasticsearch 自定义similarity 插件开发

    转自:http://www.chepoo.com/elasticsearch-similarity-custom-plug-in-development.html 在搜索开发中,我们要修改打分机制,就 ...

  6. Elasticsearch自定义分析器

    关于分析器 ES中默认使用的是标准分析器(standard analyzer).如果需要对某个字段使用其他分析器,可以在映射中该字段下说明.例如: PUT /my_index { "mapp ...

  7. elasticsearch自定义动态映射

    https://www.elastic.co/guide/cn/elasticsearch/guide/current/custom-dynamic-mapping.html如果你想在运行时增加新的字 ...

  8. ElasticSearch——自定义模板

    output中配置 elasticsearch{ action => "index" hosts => ["xxx"] index => &q ...

  9. ElasticSearch 自定义排序处理

    使用function_score进行分组处理,利用分组函数script_score进行自定义分值处理, 注意:使用script功能需要在配置中打开脚本功能: script.inline: on   s ...

随机推荐

  1. Python(一)list tuple dict set

    这篇文章是为了复习之前学的python的数据结构: 原文链接:http://www.liaoxuefeng.com/wiki/0014316089557264a6b348958f449949df42a ...

  2. Android学习04

    Toast Toast是Android系统提供的一种非常好的提示方式,在程序中可以使用它将一些短小的信息通知给用户,这些信息会在一段时间后自动消失,并且不会占用任何的屏幕空间. 1.默认Toast 在 ...

  3. 【原】django实现列表分页功能

    在view.py里添加分页查询方法: from django.http import JsonResponse from django.views.decorators.http import req ...

  4. 【PAT甲级】1085 Perfect Sequence (25 分)

    题意: 输入两个正整数N和P(N<=1e5,P<=1e9),接着输入N个正整数.输出一组数的最大个数使得其中最大的数不超过最小的数P倍. trick: 测试点5会爆int,因为P太大了.. ...

  5. rapidxml读xml文件

    student.xml文件内容: int readXML(void) { rapidxml::file<> file("student.xml"); rapidxml: ...

  6. 吴裕雄 python 神经网络——TensorFlow训练神经网络:不使用隐藏层

    import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data INPUT_NODE = 784 ...

  7. ASA-有关AAA用户登录的问题

    问题示例:I have created a test user that is set to privilege 15 in the config: When I log in to the ASA ...

  8. for in 与for 与hasOwnProperty

    在遍历一个对象的时候我们会使用到for in属性. 现有对象和数组如下: var filght = { number: 1, status: 'watit', arrival: [1,2,3], ad ...

  9. nyoj 40

    题目:http://acm.nyist.edu.cn/JudgeOnline/status.php?pid=40 求最大公约数和最小公倍数... 思路:欧几里德算法求出最大公约数,即最大公约数 = g ...

  10. 第二十九节: Asp.Net Core零散获取总结(不断补充)

    1. IWebHostEnvironment获取常用属性 (1).获取项目的根目录 _env.ContentRootPath 等价于 Directory.GetCurrentDirectory() ( ...