ES kibana常用语法---增删改查_es 空字符串值查询,2024年最新三面头条+四面阿里+五面腾讯拿offer分享面经总结

{
“query”: {
“bool”: {
“must_not”: [
{
“wildcard”: {
“字段名称”: {
“value”: “*”
}
}
}
]
}
}
}


##### 字段值不为空字符串的文档



GET index名称/_count
{
“query”: {
“wildcard”: {
“字段名称”: {
“value”: “*”
}
}
}
}


#### 1. Match Query:用于搜索指定字段中包含指定词条的文档。



GET /_search
{
“query”: {
“match”: {
“title”: “Elasticsearch”
}
}
}


#### 2. Term Query:用于搜索指定字段中包含指定词条的文档,不会对词条进行分词。



GET /_search
{
“query”: {
“term”: {
“title”: “Elasticsearch”
}
}
}


#### 3. Range Query:用于搜索指定字段中符合指定范围的文档。



GET /_search
{
“query”: {
“range”: {
“age”: {
“gte”: 18,
“lte”: 30
}
}
}
}


#### 4. Bool Query:用于组合多个查询条件,支持must、should、must\_not和filter四种子查询。



GET /_search
{
“query”: {
“bool”: {
“must”: [
{ “match”: { “title”: “Elasticsearch” }},
{ “match”: { “content”: “Java” }}
],
“should”: [
{ “match”: { “author”: “John” }},
{ “match”: { “author”: “Jane” }}
],
“must_not”: [
{ “match”: { “status”: “deleted” }}
],
“filter”: [
{ “range”: { “date”: { “gte”: “2020-01-01” }}}
]
}
}
}


#### 5. Wildcard Query:用于搜索指定字段中符合通配符表达式的文档。



GET /_search
{
“query”: {
“wildcard”: {
“title”: “Elast*csearch”
}
}
}


#### 6. Fuzzy Query:用于搜索指定字段中与指定词条相似的文档。



GET /_search
{
“query”: {
“fuzzy”: {
“title”: {
“value”: “Elastiksearch”,
“fuzziness”: “2”
}
}
}
}


#### 7. Prefix Query:用于搜索指定字段中以指定前缀开头的文档。



GET /_search
{
“query”: {
“prefix”: {
“title”: “Elast”
}
}
}


#### 8. Match Phrase Query:用于搜索指定字段中包含指定短语的文档。



GET /_search
{
“query”: {
“match_phrase”: {
“title”: “Elasticsearch tutorial”
}
}
}


### 基本查询


#### 查询某个索引所有的文档



GET /your_index_name/_search
{
“query”: {
“match_all”: {}
}
}

GET /your_index_name/_search


#### 查询字符串搜索



GET test/doc/_search?q=name:wangfei


#### 结构化查询(单字段查询,不能多字段组合查询)



GET test/doc/_search
{
“query”:{
“match”:{
“name”:“wang”
}
}
}


### match 系列


1、match:返回所有匹配的分词。


2、match\_all:查询全部。


3、match\_phrase:短语查询,在match的基础上进一步查询词组,可以指定slop分词间隔。


4、match\_phrase\_prefix:前缀查询,根据短语中最后一个词组做前缀匹配,可以应用于搜索提示,但注意和max\_expanions搭配。其实默认是50…


5、multi\_match:多字段查询,使用相当的灵活,可以完成 match\_phrase 和 match\_phrase\_prefix 的工作。


#### match\_all (查询全部)



GET test/doc/_search
{
“query”:{
“match_all”: {
}
}
}


#### match\_phrase(短语查询)



匹配一整个词语

只用match,会单个字匹配

GET test1/doc/_search { “query”:{ “match”:{ “title”:“中国” } } }


#### match\_phrase\_prefix(最左前缀查询)智能搜索–以什么开头


#### multi\_match(多字段查询)



  • multi_match是要在多个字段中查询同一个关键字 除此之外,mulit_match甚至可以当做match_phrase和match_phrase_prefix使用,只需要指定type类型即可

GET test2/doc/_search
{
“query”: {
“multi_match”: {
“query”: “beautiful”,
“fields”: [
“title”,
“desc”
]
}
}
}

  • 当设置属性 type:phrase 时 等同于 短语查询
    GET test1/doc/_search
    {
    “query”: {
    “multi_match”: {
    “query”: “中国”,
    “fields”: [
    “title”
    ],
    “type”: “phrase”
    }
    }
    }
  • 当设置属性 type:phrase_prefix时 等同于 最左前缀查询
    GET test2/doc/_search
    {
    “query”: {
    “multi_match”: {
    “query”: “bea”,
    “fields”: [
    “desc”
    ],
    “type”: “phrase_prefix”
    }
    }
    }

### 排序查询



倒排
GET test/doc/_search
{
“query”: {
“match_all”: {}
},
“sort”: [
{
“age”: {
“order”: “desc”
}
}
]
}
升序
GET test/doc/_search
{
“query”: {
“match_all”: {}
},
“sort”: [
{
“age”: {
“order”: “asc”
}
}
]
}


### 分页查询



GET test/doc/_search
{
“query”: {
“match_phrase_prefix”: {
“name”: “wang”
}
},
“from”: 0,
“size”: 1
}


### bool 查询 (must、should)


**bool 查询总结**  
 must:与关系,相当于关系型数据库中的 and。  
 should:或关系,相当于关系型数据库中的 or。  
 must\_not:非关系,相当于关系型数据库中的 not。  
 filter:过滤条件。  
 range:条件筛选范围。  
 gt:大于,相当于关系型数据库中的 >。  
 gte:大于等于,相当于关系型数据库中的 >=。  
 lt:小于,相当于关系型数据库中的 <。  
 lte:小于等于,相当于关系型数据库中的 <=。


#### must


(must字段对应的是个列表,也就是说可以有多个并列的查询条件,一个文档满足各个子条件后才最终返回)


##### 单条件查询



GET test/doc/_search
{
“query”: {
“bool”: {
“must”: [
{
“match”: {
“name”: “wangfei”
}
}
]
}
}
}


##### 多条件组合查询



GET test/doc/_search
{
“query”: {
“bool”: {
“must”: [
{
“match”: {
“name”: “wanggfei”
}
},
{
“match”: {
“age”: 25
}
}
]
}
}
}


#### should


(只要符合其中一个条件就返回)



GET test/doc/_search
{
“query”: {
“bool”: {
“should”: [
{
“match”: {
“name”: “wangjifei”
}
},
{
“match”: {
“age”: 27
}
}
]
}
}
}


#### must\_not



GET test/doc/_search
{
“query”: {
“bool”: {
“must_not”: [
{
“match”: {
“name”: “wangjifei”
}
},
{
“match”: {
“age”: 27
}
}
]
}
}
}


#### filter


(条件过滤查询,过滤条件的范围用range表示gt表示大于、lt表示小于、gte表示大于等于、lte表示小于等于)



GET test/doc/_search
{
“query”: {
“bool”: {
“must”: [
{
“match”: {
“name”: “wangjifei”
}
}
],
“filter”: {
“range”: {
“age”: {
“gte”: 10,
“lt”: 27
}
}
}
}
}
}


#### 查询结果过滤



GET test3/doc/_search
{
“query”: {
“match”: {
“name”: “顾”
}
},
“_source”: [“name”,“age”]
}

查询结果
{
“took” : 58,
“timed_out” : false,
“_shards” : {
“total” : 5,
“successful” : 5,
“skipped” : 0,
“failed” : 0
},
“hits” : {
“total” : 1,
“max_score” : 0.2876821,
“hits” : [
{
“_index” : “test3”,
“_type” : “doc”,
“_id” : “1”,
“_score” : 0.2876821,
“_source” : {
“name” : “顾老二”,
“age” : 30
}
}
]
}
}


#### 查询结果高亮显示 (默认高亮显示)



GET test3/doc/_search
{
“query”: {
“match”: {
“name”: “顾老二”
}
},
“highlight”: {
“fields”: {
“name”: {}
}
}
}

查询结果
{
“took” : 216,
“timed_out” : false,
“_shards” : {
“total” : 5,
“successful” : 5,
“skipped” : 0,
“failed” : 0
},
“hits” : {
“total” : 1,
“max_score” : 0.8630463,
“hits” : [
{
“_index” : “test3”,
“_type” : “doc”,
“_id” : “1”,
“_score” : 0.8630463,
“_source” : {
“name” : “顾老二”,
“age” : 30,
“from” : “gu”,
“desc” : “皮肤黑、武器长、性格直”,
“tags” : [
“黑”,
“长”,
“直”
]
},
“highlight” : {
“name” : [

]
}
}
]
}
}


### 精确查询与模糊查询


**term 和 match 的区别是:**  
 match 经过分词,用于模糊查询,可以查看某个字段值中的部分词  
 term 不经过分词,只能匹配到完整的字段值,用于精确查询



准备数据

PUT w1
{
“mappings”: {
“doc”: {
“properties”:{
“t1”:{
“type”: “text”
},
“t2”: {
“type”: “keyword”
}
}
}
}
}

PUT w1/doc/1
{
“t1”: “hi single dog”,
“t2”: “hi single dog”
}

t1类型为text,会经过分词,match查询时条件也会经过分词,所以下面两种查询都能查到结果

GET w1/doc/_search
{
“query”: {
“match”: {
“t1”: “hi single dog”
}
}
}

GET w1/doc/_search
{
“query”: {
“match”: {
“t1”: “hi”
}
}
}

t2类型为keyword类型,不会经过分词,match查询时条件会经过分词,所以只能当值为"hi single dog"时能查询到

GET w1/doc/_search
{
“query”: {
“match”: {
“t2”: “hi”
}
}
}

GET w1/doc/_search
{
“query”: {
“match”: {
“t2”: “hi single dog”
}
}
}

t1类型为text,会经过分词,term查询时条件不会经过分词,所以只有当值为"hi"时能查询到

GET w1/doc/_search
{
“query”: {
“term”: {
“t1”: “hi single dog”
}
}
}

GET w1/doc/_search
{
“query”: {
“term”: {
“t1”: “hi”
}
}
}

t2类型为keyword类型,不会经过分词,term查询时条件不会经过分词,所以只能当值为"hi single dog"时能查询到

GET w1/doc/_search
{
“query”: {
“term”: {
“t2”: “hi single dog”
}
}
}

GET w1/doc/_search
{
“query”: {
“term”: {
“t2”: “hi”
}
}
}

  • 查找多个精确值(terms)
第一个查询方式

GET test/doc/_search
{
“query”: {
“bool”: {
“should”: [
{
“term”: {
“age”:27
}
},{
“term”:{
“age”:28
}
}
]
}
}
}

第二个查询方式

GET test/doc/_search
{
“query”: {
“terms”: {
“age”: [
“27”,
“28”
]
}
}
}


### 聚合查询 avg、max、min、sum



数据准备

PUT zhifou/doc/1
{
“name”:“顾老二”,
“age”:30,
“from”: “gu”,
“desc”: “皮肤黑、武器长、性格直”,
“tags”: [“黑”, “长”, “直”]
}

PUT zhifou/doc/2
{
“name”:“大娘子”,
“age”:18,
“from”:“sheng”,
“desc”:“肤白貌美,娇憨可爱”,
“tags”:[“白”, “富”,“美”]
}

PUT zhifou/doc/3
{
“name”:“龙套偏房”,
“age”:22,
“from”:“gu”,
“desc”:“mmp,没怎么看,不知道怎么形容”,
“tags”:[“造数据”, “真”,“难”]
}

PUT zhifou/doc/4
{
“name”:“石头”,
“age”:29,
“from”:“gu”,
“desc”:“粗中有细,狐假虎威”,
“tags”:[“粗”, “大”,“猛”]
}

PUT zhifou/doc/5
{
“name”:“魏行首”,
“age”:25,
“from”:“广云台”,
“desc”:“仿佛兮若轻云之蔽月,飘飘兮若流风之回雪,mmp,最后竟然没有嫁给顾老二!”,
“tags”:[“闭月”,“羞花”]
}

GET zhifou/doc/_search
{
“query”: {
“match_all”: {}
}
}

  • 需求1、查询from是gu的人的平均年龄。
    GET zhifou/doc/_search
    {
    “query”: {
    “match”: {
    “from”: “gu”
    }
    },
    “aggs”: {
    “my_avg”: {
    “avg”: {
    “field”: “age”
    }
    }
    },
    “_source”: [“name”, “age”]
    }

查询结果
{
“took” : 83,
“timed_out” : false,
“_shards” : {
“total” : 5,
“successful” : 5,
“skipped” : 0,
“failed” : 0
},
“hits” : {
“total” : 3,
“max_score” : 0.6931472,
“hits” : [
{
“_index” : “zhifou”,
“_type” : “doc”,
“_id” : “4”,
“_score” : 0.6931472,
“_source” : {
“name” : “石头”,
“age” : 29
}
},
{
“_index” : “zhifou”,
“_type” : “doc”,
“_id” : “1”,
“_score” : 0.2876821,
“_source” : {
“name” : “顾老二”,
“age” : 30
}
},
{
“_index” : “zhifou”,
“_type” : “doc”,
“_id” : “3”,
“_score” : 0.2876821,
“_source” : {
“name” : “龙套偏房”,
“age” : 22
}
}
]
},
“aggregations” : {
“my_avg” : {
“value” : 27.0
}
}
}

上例中,首先匹配查询from是gu的数据。在此基础上做查询平均值的操作,这里就用到了聚合函数,其语法被封装在aggs中,而my_avg则是为查询结果起个别名,封装了计算出的平均值。那么,要以什么属性作为条件呢?是age年龄,查年龄的什么呢?是avg,查平均年龄。
如果只想看输出的值,而不关心输出的文档的话可以通过size=0来控制

GET zhifou/doc/_search
{
“query”: {
“match”: {
“from”: “gu”
}
},
“aggs”:{
“my_avg”:{
“avg”: {
“field”: “age”
}
}
},
“size”:0,
“_source”:[“name”,“age”]
}

查询结果
{
“took” : 35,
“timed_out” : false,
“_shards” : {
“total” : 5,
“successful” : 5,
“skipped” : 0,
“failed” : 0
},
“hits” : {
“total” : 3,
“max_score” : 0.0,
“hits” : [ ]
},
“aggregations” : {
“my_avg” : {
“value” : 27.0
}
}
}


* 需求2、查询年龄的最大值



GET zhifou/doc/_search
{
“query”: {
“match_all”: {}
},
“aggs”: {
“my_max”: {
“max”: {
“field”: “age”
}
}
},
“size”: 0,
“_source”: [“name”,“age”,“from”]
}

查询结果
{
“took” : 10,
“timed_out” : false,
“_shards” : {
“total” : 5,
“successful” : 5,
“skipped” : 0,
“failed” : 0
},
“hits” : {
“total” : 5,
“max_score” : 0.0,
“hits” : [ ]
},
“aggregations” : {
“my_max” : {
“value” : 30.0
}
}
}


* 需求3、查询年龄的最小值



GET zhifou/doc/_search
{
“query”: {
“match_all”: {}
},
“aggs”: {
“my_min”: {
“min”: {
“field”: “age”
}
}
},
“size”: 0,
“_source”: [“name”,“age”,“from”]
}

查询结果
{
“took” : 2,
“timed_out” : false,
“_shards” : {
“total” : 5,
“successful” : 5,
“skipped” : 0,
“failed” : 0
},
“hits” : {
“total” : 5,
“max_score” : 0.0,
“hits” : [ ]
},
“aggregations” : {
“my_min” : {
“value” : 18.0
}
}
}


* 需求4、查询符合条件的年龄之和



GET zhifou/doc/_search
{
“query”: {
“match”: {
“from”: “gu”
}
},
“aggs”: {
“my_sum”: {
“sum”: {
“field”: “age”
}
}
},
“size”: 0,
“_source”: [“name”,“age”,“from”]
}

查询结果
{
“took” : 4,
“timed_out” : false,
“_shards” : {
“total” : 5,
“successful” : 5,
“skipped” : 0,
“failed” : 0
},
“hits” : {
“total” : 3,
“max_score” : 0.0,
“hits” : [ ]
},
“aggregations” : {
“my_sum” : {
“value” : 81.0
}
}
}


### 分组查询


* 需求: 要查询所有人的年龄段,并且按照1520,2025,25~30分组,并且算出每组的平均年龄。



GET zhifou/doc/_search
{
“size”: 0,
“query”: {
“match_all”: {}
},
“aggs”: {
“age_group”: {
“range”: {
“field”: “age”,
“ranges”: [
{
“from”: 15,
“to”: 20
},
{
“from”: 20,
“to”: 25
},
{
“from”: 25,
“to”: 30
}
]
}
}
}
}

查询结果
{
“took” : 9,
“timed_out” : false,
“_shards” : {
“total” : 5,
“successful” : 5,
“skipped” : 0,
“failed” : 0
},
“hits” : {
“total” : 5,
“max_score” : 0.0,
“hits” : [ ]
},
“aggregations” : {
“age_group” : {
“buckets” : [
{
“key” : “15.0-20.0”,
“from” : 15.0,
“to” : 20.0,
“doc_count” : 1
},
{
“key” : “20.0-25.0”,
“from” : 20.0,
“to” : 25.0,
“doc_count” : 1
},
{
“key” : “25.0-30.0”,
“from” : 25.0,
“to” : 30.0,
“doc_count” : 2
}
]
}
}
}


上例中,在aggs的自定义别名age\_group中,使用range来做分组,field是以age为分组,分组使用ranges来做,from和to是范围


* 接下来,我们就要对每个小组内的数据做平均年龄处理。



GET zhifou/doc/_search
{
“size”: 0,
“query”: {
“match_all”: {}
},
“aggs”: {
“age_group”: {
“range”: {
“field”: “age”,
“ranges”: [
{
“from”: 15,
“to”: 20
},
{
“from”: 20,
“to”: 25
},
{
“from”: 25,
“to”: 30
}
]
},
“aggs”: {
“my_avg”: {
“avg”: {
“field”: “age”
}
}
}
}
}
}

查询结果
{
“took” : 1,
“timed_out” : false,
“_shards” : {
“total” : 5,
“successful” : 5,
“skipped” : 0,
“failed” : 0
},
“hits” : {
“total” : 5,
“max_score” : 0.0,
“hits” : [ ]
},
“aggregations” : {
“age_group” : {
“buckets” : [
{
“key” : “15.0-20.0”,
“from” : 15.0,
“to” : 20.0,
“doc_count” : 1,
“my_avg” : {
“value” : 18.0
}
},
{
“key” : “20.0-25.0”,
“from” : 20.0,
“to” : 25.0,
“doc_count” : 1,
“my_avg” : {
“value” : 22.0
}
},
{
“key” : “25.0-30.0”,
“from” : 25.0,
“to” : 30.0,
“doc_count” : 2,
“my_avg” : {
“value” : 27.0
}
}
]
}
}
}



> 
> ES的聚合查询的总结:聚合函数的使用,一定是先查出结果,然后对结果使用聚合函数做处理
> 
> 
> avg:求平均
> 
> 
> max:最大值
> 
> 
> min:最小值
> 
> 
> sum:求和
> 
> 
> 


## mapping


### mapping 是什么


映射,用于定义一个文档及其中的字段如何存储和索引


### 字段的数据类型



> 
> 简单类型如文本(text)、关键字(keyword)、日期(data)、整形(long)、双精度>、(double)、布尔(boolean)或 ip。  
>  可以是支持 JSON 的层次结构性质的类型,如对象或嵌套。  
>  或者一种特殊类型,如 geo\_point、geo\_shape 或 completion。为了不同的目的,  
>  以不同的方式索引相同的字段通常是有用的。例如,字符串字段可以作为全文搜索的文本字段进行索引,  
>  也可以作为排序或聚合的关键字字段进行索引。或者,可以使用标准分析器、英语分析器和  
>  法语分析器索引字符串字段。这就是多字段的目的。大多数数据类型通过 fields 参数支持多字段。
> 
> 
> 


### mappings 之 dynamic 的三种状态


ES 中的 mapping 用来定义索引中字段和字段属性。mapping 中的 dynamic 属性决定了新增字段的处理方式,它有三种状态:


1. true (默认值)


当 dynamic 设置为 true 时,如果文档中出现新的字段,ES 会自动将这个字段添加到 mapping 定义中,并根据字段值自动识别其类型。


2. false


当 dynamic 设置为 false 时,如果文档中出现新的字段,ES 不会自动将这个字段添加到 mapping, 而是忽略这个新增字段。


3. strict


当 dynamic 设置为 strict 时,如果文档中出现新的字段,ES 不仅不会添加这个字段到 mapping, 还会抛出异常错误。


总的来说,dynamic 属性用来控制新增字段的处理模式:


* true 会自动添加字段
* false 会忽略新增字段
* strict 会报错


通过设置不同的 dynamic 状态,可以更好地管理索引的 mapping 定义和字段。这对控制数据结构非常重要。



默认为动态映射

PUT test4
{
“mappings”: {
“doc”:{
“properties”: {
“name”: {
“type”: “text”
},
“age”: {
“type”: “long”
}
}
}
}
}

GET test4/_mapping

查询结果
{
“test4” : {
“mappings” : {
“doc” : {
“properties” : {
“age” : {
“type” : “long”
},
“name” : {
“type” : “text”
},
“sex” : {
“type” : “text”,
“fields” : {
“keyword” : {
“type” : “keyword”,
“ignore_above” : 256
}
}
}
}
}
}
}
}

#####添加数据
PUT test4/doc/1
{
“name”:“wangjifei”,
“age”:“18”,
“sex”:“不详”
}

#####查看数据
GET test4/doc/_search
{
“query”: {
“match_all”: {}
}
}

查询结果
{
“took” : 8,
“timed_out” : false,
“_shards” : {
“total” : 5,
“successful” : 5,
“skipped” : 0,
“failed” : 0
},
“hits” : {
“total” : 1,
“max_score” : 1.0,
“hits” : [
{
“_index” : “test4”,
“_type” : “doc”,
“_id” : “1”,
“_score” : 1.0,
“_source” : {
“name” : “wangjifei”,
“age” : “18”,
“sex” : “不详”
}
}
]
}
}


* 测试静态映射:当elasticsearch察觉到有新增字段时,因为dynamic:false的关系,会忽略该字段,但是仍会存储该字段。



#####创建静态mapping
PUT test5
{
“mappings”: {
“doc”:{
“dynamic”:false,
“properties”: {
“name”: {
“type”: “text”
},
“age”: {
“type”: “long”
}
}
}
}
}

#####插入数据
PUT test5/doc/1
{
“name”:“wangjifei”,
“age”:“18”,
“sex”:“不详”
}

####条件查询
GET test5/doc/_search
{
“query”: {
“match”: {
“sex”: “不详”
}
}
}

查询结果
{
“took” : 9,
“timed_out” : false,
“_shards” : {
“total” : 5,
“successful” : 5,
“skipped” : 0,
“failed” : 0
},
“hits” : {
“total” : 0,
“max_score” : null,
“hits” : [ ]
}
}

#####查看所有数据
GET /test5/doc/_search
{
“query”: {
“match_all”: {}
}
}

查询结果
{
“took” : 1,
“timed_out” : false,
“_shards” : {
“total” : 5,
“successful” : 5,
“skipped” : 0,
“failed” : 0
},
“hits” : {
“total” : 1,
“max_score” : 1.0,
“hits” : [
{
“_index” : “test5”,
“_type” : “doc”,
“_id” : “1”,
“_score” : 1.0,
“_source” : {
“name” : “wangjifei”,
“age” : “18”,
“sex” : “不详”
}
}
]
}
}


* 测试严格映射:当elasticsearch察觉到有新增字段时,因为dynamic:strict 的关系,就会报错,不能插入成功。



#####创建严格mapping
PUT test6
{
“mappings”: {
“doc”:{
“dynamic”:“strict”,
“properties”: {
“name”: {
“type”: “text”
},
“age”: {
“type”: “long”
}
}
}
}
}

#####插入数据
PUT test6/doc/1
{
“name”:“wangjifei”,
“age”:“18”,
“sex”:“不详”
}

插入结果
{
“error”: {
“root_cause”: [
{
“type”: “strict_dynamic_mapping_exception”,
“reason”: “mapping set to strict, dynamic introduction of [sex] within [doc] is not allowed”
}
],
“type”: “strict_dynamic_mapping_exception”,
“reason”: “mapping set to strict, dynamic introduction of [sex] within [doc] is not allowed”
},
“status”: 400
}



> 
> 小结: 动态映射(dynamic:true):动态添加新的字段(或缺省)。静态映射(dynamic:false):忽略新的字段。在原有的映射基础上,当有新的字段时,不会主动的添加新的映射关系,只作为查询结果出现在查询中。严格模式(dynamic:strict):如果遇到新的字段,就抛出异常。一般静态映射用的较多。就像 HTML 的 img 标签一样,src 为自带的属性,你可以在需要的时候添加 id 或者 class 属性。当然,如果你非常非常了解你的数据,并且未来很长一段时间不会改变,strict 不失为一个好选择。
> 
> 
> 


### ES 之 mappings 的 index 属性


* index属性默认为true,如果该属性设置为false,那么,elasticsearch不会为该属性创建索引,也就是说无法当做主查询条件。



PUT test7
{
“mappings”: {
“doc”: {
“properties”: {
“name”: {
“type”: “text”,
“index”: true

自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。

深知大多数大数据工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则几千的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!

因此收集整理了一份《2024年大数据全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友。
img
img
img
img
img

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上大数据开发知识点,真正体系化!

由于文件比较大,这里只是将部分目录大纲截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且后续会持续更新

如果你觉得这些内容对你有帮助,可以添加VX:vip204888 (备注大数据获取)
img

一个人可以走的很快,但一群人才能走的更远。不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎扫码加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

n",
“reason”: “mapping set to strict, dynamic introduction of [sex] within [doc] is not allowed”
}
],
“type”: “strict_dynamic_mapping_exception”,
“reason”: “mapping set to strict, dynamic introduction of [sex] within [doc] is not allowed”
},
“status”: 400
}



> 
> 小结: 动态映射(dynamic:true):动态添加新的字段(或缺省)。静态映射(dynamic:false):忽略新的字段。在原有的映射基础上,当有新的字段时,不会主动的添加新的映射关系,只作为查询结果出现在查询中。严格模式(dynamic:strict):如果遇到新的字段,就抛出异常。一般静态映射用的较多。就像 HTML 的 img 标签一样,src 为自带的属性,你可以在需要的时候添加 id 或者 class 属性。当然,如果你非常非常了解你的数据,并且未来很长一段时间不会改变,strict 不失为一个好选择。
> 
> 
> 


### ES 之 mappings 的 index 属性


* index属性默认为true,如果该属性设置为false,那么,elasticsearch不会为该属性创建索引,也就是说无法当做主查询条件。



PUT test7
{
“mappings”: {
“doc”: {
“properties”: {
“name”: {
“type”: “text”,
“index”: true

自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。

深知大多数大数据工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则几千的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!

因此收集整理了一份《2024年大数据全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友。
[外链图片转存中…(img-uSQEgUpI-1712960090458)]
[外链图片转存中…(img-mUAPCMGA-1712960090459)]
[外链图片转存中…(img-oqCcSyEy-1712960090459)]
[外链图片转存中…(img-lVdTa9xR-1712960090459)]
[外链图片转存中…(img-YKNo9bQq-1712960090459)]

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上大数据开发知识点,真正体系化!

由于文件比较大,这里只是将部分目录大纲截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且后续会持续更新

如果你觉得这些内容对你有帮助,可以添加VX:vip204888 (备注大数据获取)
[外链图片转存中…(img-VTO9otUF-1712960090460)]

一个人可以走的很快,但一群人才能走的更远。不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎扫码加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

  • 11
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值