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 .

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: 

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

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

测试查询第所有数据

GET /cf_etf_dividend_denormalize/_search

在这里插入图片描述

GET /cf_etf_dividend_denormalize/_search

{
  "query": {
    "bool": {
      "must": [
        {"range": {
          "exDate": {
            "gte": "2019-06-15",
            "lte": "2019-06-19"
          }
        }}
      ]
    }
  }
}
查询字段
GET /cf_etf_dividend_denormalize/_search
{
  "query": {
    "bool": {
      "must": [
        {"range": {
          "announcement.exDate": {
            "gte": "2019-06-17" 
          }
        }
        },
        {
          "match": {
            "symbol": "ACWF"
          }
        }
      ]
    }
  }
}

结果

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值