es笔记20240417
https://www.elastic.co/guide/en/elasticsearch/reference/5.6/query-dsl-range-query.html
数据类型
是否允许强制转换
演示
设置所有字段不支持强制转换
https://www.elastic.co/guide/en/elasticsearch/reference/5.6/coerce.html
PUT my_index { "settings": { "index.mapping.coerce": false }, "mappings": { "my_type": { "properties": { "number_one": { "type": "integer", "coerce": true }, "number_two": { "type": "integer" } } } } }
copy_to 不可见但是可用用query查到
倒排索引 doc_value 关闭倒排索引后query搜索不到
关闭倒排索引的类型type必须是object
子字段"ignore_above": 10 长度为10
POST index_test/_search { "query": { "match": { "name": "2" } } } PUT index_test { "mappings": { "user": { "properties": { "title": { "type": "object", "enabled": false } } } } } POST index_test/user/ { "title" : 1 } GET index_test/_search/ POST index_test/_search { "query": { "match": { "title": 1 } } } DELETE index_test PUT index_test { "mappings": { "user": { "properties": { "language": { "type": "text", "fields": { "chinaes":{ "type": "keyword", "ignore_above": 10 }, "english":{ "type": "text", "analyzer": "english" } } } } } } } POST index_test/user/ { "language" : "chinaes11111" } POST index_test/_search { "query": { "match": { "language.chinaes": "chinaes11111" } } }
index:false 不创建倒排索引
"enabled": false 不创建倒排索引源文档存在
禁用评分
keywork類型
term精准查询
match text类型查询
keywork类型超过预值会丢弃
GET upload.zzt.nginx-2024.04.16/_search?size=19 GET upload.zzt.nginx-2024.04.16/_search?from=9&size=10 POST upload.zzbm.nginx-2024.04.17/_search { "query": { "range" : { "request_length" : { "gte" : 2097152 } } } } PUT index_test GET index_test DELETE index_test POST upload.zzt.nginx-2024.04.16/_search { "size":1, "query":{ "match":{ "remote_addr": "180.169.252.26" } } } GET upload.zzbm.nginx-2024.04.16 PUT index_test { "settings": { "number_of_replicas": 1, "number_of_shards": 1 } } HEAD index_test GET index_test/_count PUT index_test/fluentd/1 { "source":1 } POST _reindex { "source": { "index": "index_test" }, "dest": { "index": "index_test_new" } } GET _cat/indices GET index_test/_search POST index_test/fluentd/ { "user" : "kimchy", "post_date" : "2009-11-15T14:12:12", "message" : "trying out Elasticsearch" } GET index_test/_mapping GET index_test/fluentd/AY7nRo16Vp-76aWrJPwe POST upload.zzt.nginx-2024.04.16/_search { "size":0, "query":{ "match":{ "remote_addr": "180.169.252.26" } } } GET index_test/fluentd/AY7nRo16Vp-76aWrJPwe?_source=false GET index_test/fluentd/_search GET upload.zzbm.nginx-2024.04.16/_mapping GET upload.zzbm.nginx-2024.04.16/_search/ GET upload.zzbm.nginx-2024.04.16/fluentd/AY7kVwcJVp-76aWr-Fto GET upload.zzbm.nginx-2024.04.16/_mapping/field/remote_addr PUT index_test { "mappings": { "user": { "properties": { "title": { "type": "text", "fielddata": true, "analyzer": "standard" }, "age": { "type": "integer" } } }, "blogpost": { "properties": { "user_id": { "type": "keyword" }, "created": { "type": "date", "format": "strict_date_optional_time||epoch_millis" } } } } } PUT index_test/_mapping/user { "properties": { "title": { "type": "text", "fielddata": true } } } PUT index_test/_mapping/user { "properties": { "title": { "type": "text", "fielddata": true, "analyzer": "standard" } } } PUT index_test { "mappings": { "user": { "properties": { "title": { "type": "text", "fielddata": true, "analyzer": "standard", "coerce": false } } } } } POST index_test/user/ { "title" : "kimchy" } GET index_test/_search PUT index_test { "mappings": { "user": { "properties": { "title": { "type": "integer", "coerce": false, "copy_to": "name" }, "name": { "type": "text" } } } } } POST index_test/user/ { "title" : 1 } GET index_test/_search/ GET index_test/user/AY7nwRmzVp-76aWrOYF2?_source==true POST index_test/_search { "query": { "match": { "name": "2" } } } PUT index_test { "mappings": { "user": { "properties": { "title": { "type": "object", "enabled": false } } } } } POST index_test/user/ { "title" : 1 } GET index_test/_search/ POST index_test/_search { "query": { "match": { "title": 1 } } } DELETE index_test PUT index_test { "mappings": { "user": { "properties": { "language": { "type": "text", "fields": { "chinaes":{ "type": "keyword", "ignore_above": 10 }, "english":{ "type": "text", "analyzer": "english" } } } } } } } POST index_test/user/1 { "language" : "chinaes11111" } POST index_test/_search { "query": { "match": { "language.english": "chinaes11111" } } } PUT index_test { "mappings": { "user": { "properties": { "language": { "type": "text", "index": false } } } } } POST index_test/user/1 { "language" : "chinaes11111" } GET index_test/_search POST index_test/_search { "query": { "match": { "language": "chinaes11111" } } } PUT index_test { "mappings": { "user": { "properties": { "name": { "type": "text", "store": true }, "age": { "type": "integer", "store": true }, "data": { "type": "date" } } } } } POST index_test/user/1 { "name" : "tiantao", "age" : 34, "data": "20240417" } PUT index_test { "mappings": { "user": { "properties": { "name": { "type": "text", }, "age": { "type": "integer", }, "data": { "type": "date" } } } } } POST /index_test/_search { "_source": ["name", "data"] } GET upload.zzbm.nginx-2024.04.17/_mapping
时间类型
复杂类型 例如字典
动态映射
参考:https://www.cnblogs.com/wangzhuxing/p/9527151.html#_label0_0
自定义只能在指定索引内
同义词