zoukankan      html  css  js  c++  java
  • es-快速分析DSL语句记录

    1、修改时间字段的format:

    PUT index_name
    {
        "mappings": {
            "_doc": {
                "properties": {
                    "create_time": {
                          "type": "date",
                          "format": "yyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis||yyyyMMddhhmmss"
                      }
                 }
            }
        }
    }            

    2、创建一个text字段,并设置为多字段(keyword)

    PUT index_name?pretty
    {
       "mappings": {
          "_doc": {
              "properties": {
                   "field111": { 
                        "type": "text",
                        "fields": {
                             "keyword": { 
                                 "type": "keyword"
                              }
                         }
                     }
               }
           }
       }
    }

    3、字段是否单独存储一次:

    {
        "mappings": {
             "_doc": {
                  "properties": {
                        "title": {
                               "type": "text",
                               "store": true 
                         },
                         "log_time": {
                               "type": "date",
                               "store": true 
                          },
                         "content": {
                                "type": "text"
                          }
                   }
             }
        }
    }

    4、在setting中自定义一个normalizer,并在mapping中使用 

    PUT index
    {
        "settings": {
             "analysis": {
                   "normalizer": {
                        "my_normalizer": {
                              "type": "custom",
                              "char_filter": [],
                              "filter": ["lowercase", "asciifolding"]
                         }
                    }
              }
         },
         "mappings": {
              "_doc": {
                   "properties": {
                        "foo": {
                             "type": "keyword",
                             "normalizer": "my_normalizer"
                         }
                    }
              }
         }
    }

    5、_source属性定义哪些字段只索引但不存储

    PUT 'localhost:9200/logs
    {
          "mappings": {
               "event": {
                    "_source": {
                           "includes": [
                               "*.count",
                               "meta.*"
                           ],
                          "excludes": [
                               "meta.description",
                               "meta.other.*"
                          ]
                    }
               }
          }
    } 

    6、在线分析索引后的结果

    //使用whitespace分析器时
    POST _analyze {
    "analyzer": "whitespace", "text": "The quick brown fox." }
    //使用自定义组合的standard分词器+2个词元过滤器(小写+停词) POST _analyze {
    "tokenizer": "standard", "filter": [ "lowercase", "stop" ], "text": "The 2 QUICK Brown-Foxes jumped over the lazy dog's bone." }

    7、message太长,只索引不存储

    PUT yb_idx/_mapping
    {
          "_source": {
                 "excludes": [ "message"]
           },
           "properties": {
                "log_id": {
                      "type": "keyword"
                  },
                "message": {
                      "type": "text"
                 },
                 "log_size": {
                     "type": "integer"
                 }
             }
    }

    8、实验match查询

    {
        "query": {
             "match": {
                 "message": "中国人民"
             }
         }
    }
  • 相关阅读:
    java的各种日志框架
    (4)一起来看下mybatis框架的缓存原理吧
    (3)一起来看下使用mybatis框架的select语句的源码执行流程吧
    Markdown基本语法
    openstack中使用linux_bridge实现vxlan网络
    python基础—第一句Python语句以及条件语句
    Java内存详解
    Java工具类练习题和答案
    面向过程和面向对象
    网页设计案例
  • 原文地址:https://www.cnblogs.com/yb38156/p/14582356.html
Copyright © 2011-2022 走看看