栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

Elastic Stack从入门到实践之Mapping

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Elastic Stack从入门到实践之Mapping

What‘s is Mapping?

自定义mapping

Mapping中的字段类型一旦设定后,禁止直接修改,原因如下:
Lucene实现的倒排索引生成后不允许修改
重新建立新的索引,然后做reindex操作
无法对新增字段进行查询操作

PUT my_index
{
  "mappings": {
    "doc" : {
      "dynamic" : false,
      "properties": {
 "title" : {
   "type":"text"
 },
 "name": {
   "type":"keyword"
 },
 "age": {
   "type": "integer"
 }
      }
    }
  }
}

GET my_index/_mapping
copy_to

DELETE my_index
PUT my_index 
{
  "mappings": {
    "doc": {
      "properties": {
 "first_name": {
   "type": "text",
   "copy_to": "full_name"
 },
 "last_name": {
   "type": "text",
   "copy_to": "full_name"
 },
 "full_name":{
   "type": "text"
 }
      }
    }
  }
}

PUT my_index/doc/1
{
  "first_name": "John",
  "last_name": "Smith"
}

GET my_index/_search
{
  "query": {
    "match": {
      "full_name" : {
 "query": "John",
 "operator": "and"
      }
    }
  }
}
index

私密信息,节省空间(因为该字段不再使用倒排索引搜索)

index_options

null_value

数据类型
  • text分词,keyword不分词

dynamic-mapping

dynamic-mapping 日期与数字识别

Dynamic Templates

索引模板

ES有一些自带的模板,小心和自定义模板引起冲突

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/222968.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号