栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 前沿技术 > 大数据 > 大数据系统

Kibana 上Es常用语句

Kibana 上Es常用语句

Kibana 上Es常用小干货

1、新建索引

PUT account_20211130_1717
{
  "settings": {
      "index": {
        "number_of_shards": "4",
        "max_result_window": "1000000",
        "analysis": {
          "filter": {
            "shingle_filter": {
              "max_shingle_size": "20",
              "min_shingle_size": "2",
              "output_unigrams": "true",
              "type": "shingle"
            },
            "ngram_limit_filter": {
              "type": "limit",
              "max_token_count": "512"
            }
          },
          "char_filter": {
            "t2s": {
              "type": "mapping",
              "mappings_path": "t2s.dic"
            },
            "my_stopword": {
              "type": "mapping",
              "mappings": [
                "\u0020 => ",
                "  => "
              ]
            }
          },
          "analyzer": {
            "whitespace_analyzer": {
              "filter": [
                "standard",
                "lowercase"
              ],
              "char_filter": [
                "t2s"
              ],
              "tokenizer": "whitespace"
            },
            "ngram_analyzer": {
              "filter": [
                "standard",
                "lowercase",
                "ngram_limit_filter"
              ],
              "char_filter": [
                "my_stopword",
                "t2s"
              ],
              "tokenizer": "ngram_tokenizer"
            },
            "keyword_analyzer": {
              "filter": [
                "lowercase"
              ],
              "tokenizer": "keyword_tokenizer"
            },
            "wordbreaker_max_analyzer": {
              "filter": [
                "standard"
              ],
              "char_filter": [
                "t2s"
              ],
              "tokenizer": "ik_max_word"
            },
            "pinyin_analyzer": {
              "filter": [
                "standard",
                "lowercase",
                "word_delimiter",
                "shingle_filter"
              ],
              "tokenizer": "pinyin_tokenizer"
            },
            "wordbreaker_smart_analyzer": {
              "filter": [
                "standard"
              ],
              "char_filter": [
                "t2s"
              ],
              "tokenizer": "ik_smart"
            }
          },
          "tokenizer": {
            "keyword_tokenizer": {
              "type": "keyword",
              "buffer_size": "1024"
            },
            "pinyin_tokenizer": {
              "padding_char": " ",
              "type": "pinyin",
              "first_letter": "none"
            },
            "ngram_tokenizer": {
              "type": "nGram",
              "min_gram": "1",
              "max_gram": "100"
            }
          }
        },
        "number_of_replicas": "1"
      }
    },
  "mappings": {
      "main": {
        "dynamic": "false",
        "properties": {
          
          "account_id": {
            "type": "integer"
          }
        }
      }
    }
}

2、es数据复制reindex

POST _reindex
{
  "source": {
    "index": "account_20210322_1000"
  },
  "dest": {
    "index": "account_20211130_1717"
  }
}

3、es索引别名操作aliases

POST _aliases
{
  "actions": [
    {
      "add": {
        "index": "account_20211130_1717",
        "alias": "account"
      }
    },
    {
      "remove": {
        "index": "account_20210322_1000",
        "alias": "account"
      }
    }
  ]
}

4、删除索引

DELETE account_20210322_1000

5、给索引增加字段

PUT item_export/main/_mapping
{
  "properties": {
    "trinity_gross_profit_ratio":{
      "type": "float"
    }
  }
}

6、删除By查询条件delete_by_query

POST account/_delete_by_query
{
  "size": 210, 
  "query": {
    "bool": {
      "must_not": [
        {
          "bool": {
            "filter": {
              "exists": {
                "field": "is_deleted"
              }
            }
          }
        }
      ],
      "filter": [
        
        {"exists": {
          "field": "business_deviser_id"
        }}
      ],
      "adjust_pure_negative": true,
      "boost": 1
    }
  }
}

7、判断nested结构参数不为空

#nested结构判断不为空
GET item_export/_search
{
  "_source": ["order_brand_list","account_id"], 
  "query": {
    "nested": {
      "path": "order_brand_list",
      "query": {
        "bool": {
          "must": {
            "exists": {
              "field": "order_brand_list"
            }
          }
        }
      }
    }
  }
}

8、更新By查询update_by_query

POST account/_update_by_query
{
  "script": {
    "source": "ctx._source.a_on_shelf_status=params.a_on_shelf_status",
    "lang": "painless",
    "params": {
      "a_on_shelf_status": 4
    }
  },
  "query": {
    "term": {
      "account_id": "3"
    }
  }
}
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/662873.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号