为什么 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"
}
}
]
}
}
}
结果