• Elastcisearch 读书笔记


    为什么 Mapping types 被移除

    the main reason was that tables are independent of each other in an SQL database.
    However, fields with the same name in (different mapping types of the same index )are the same
    表在数据库中 是独立不同的, 然而 fields 拥有相同的名字 ,字段(fields )在相同的索引里面 不同的映射类型里 是相同的
    假设在数据库(elsticsearch )中 你定义了一个老师(mapping) 有name(field)属性 ,定义 了学生 有name 属性 ,然后 你删了老师 name字段 ,学 生的也跟着删除了

    elacticsearch 与 mysql 对应关系

    在这里插入图片描述

    在这里插入图片描述
    documen 和mongodb中的一样

    分词器原理

    在这里插入图片描述

    A standard tokenizer(分词器) provides a grammar-based tokenization(基于词语切分). A lowercase token  filter normalizes the token text to lowercase, where a stop token filter removes the stop words from token streams. For a list of English stop words, you can refer to https:/​/​www. ranks.​nl/​stopwords. Let's test the standard analyzer with the input text You'll love Elasticsearch 7.0 .
    
    • 1

    A lowercase token filter 大写转小写
    a stop token filter :词元过滤器 : i love you 变成 【i , love , you】

    插入作者提供的数据

    Data denormalization
    To denormalize data is to establish relationships by keeping one or more redundant fields in each document to maintain a flat structure. Since each document contains all of the information needed to determine whether the query is met, additional joins of the documents among the indices can be avoided. The advantage of data denormalization is speed. Let's try to practice data denormalization to expand our system. In our GitHub repository (https:/​/​github.​com/​PacktPublishing/​Mastering-​Elasticsearch-​7.​0/​tree/master/​Chapter07), you can download two files,
    cf_etf_dividend_denormalize_bulk.json and
    cf_etf_dividend_denormalize_bulk_index.sh. You need to make the bash file runnable and then you can run it to index these documents.
    We will use the default settings and dynamic mapping to create an index
    named cf_etf_dividend_denormalize. There is a sample ETF, ACWF, in
    the cf_etf_dividend_denormalize_bulk.json file. We have separated each dividend record manually as a document using the IEX data. There are 10 dividend records with the ACWF ETF. We have also associated the corresponding symbol field and value with each ETF. Let's take a look at the dynamic mapping of the
    cf_etf_dividend_denormalize index generated by Elasticsearch after indexing, as shown in the following screenshot: 
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    注意 他的 json 文件名一定要和 crul 指令上的一样

    https://github.com/PacktPublishing/Mastering-Elasticsearch-7.0
    
    • 1

    测试查询第所有数据

    GET /cf_etf_dividend_denormalize/_search
    
    • 1

    在这里插入图片描述

    GET /cf_etf_dividend_denormalize/_search
    
    {
      "query": {
        "bool": {
          "must": [
            {"range": {
              "exDate": {
                "gte": "2019-06-15",
                "lte": "2019-06-19"
              }
            }}
          ]
        }
      }
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    查询字段
    GET /cf_etf_dividend_denormalize/_search
    {
      "query": {
        "bool": {
          "must": [
            {"range": {
              "announcement.exDate": {
                "gte": "2019-06-17" 
              }
            }
            },
            {
              "match": {
                "symbol": "ACWF"
              }
            }
          ]
        }
      }
    }
    
    结果
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24

    在这里插入图片描述

  • 相关阅读:
    Exception in thread “main“ java.sql.SQLException: No suitable driver
    初始结构体
    熟悉Vue路由的beforeEach陷入死循环的情况
    Android手机连接电脑弹出资源管理器
    基于SSM微信小程序的邢台市域直通公交毕业设计-附源码211514
    揭秘MMAdapt:如何利用AI跨领域战胜新兴健康谣言?
    流行的 Web 框架安全性比较
    失控的返回值
    Server - Kubernetes (K8S) 运行 PyTorchJob 的 YAML 配置
    2023年山东省安全员C证证考试题库及山东省安全员C证试题解析
  • 原文地址:https://blog.csdn.net/weixin_45699541/article/details/126334059