【大数据----ElasticSearch】建表命令

【建表】ElasticSearch建表命令

使用google插件Postman

发送方式为PUTurl地址:

192.168.2.11:9200/IndexName

文本raw,数据为json格式

{
    "settings":{
        "number_of_shards":5,
        "number_of_replicas":1
    },
    "mappings":{
        "TypeName":{
            "dynamic":"strict",
            "properties":{
                "tableId":{"type":"string","store":"yes","index":"not_analyzed"},
                "title":{"type":"string","store":"yes","index":"analyzed","analyzer": "ik_max_word","search_analyzer": "ik_max_word"},
                "author":{"type":"string","store":"yes","index":"analyzed","analyzer": "ik_max_word","search_analyzer": "ik_max_word"},
                "summary":{"type":"string","store":"yes","index":"analyzed","analyzer": "ik_max_word","search_analyzer": "ik_max_word"},
                "contextSrc":{"type":"string","store":"yes","index":"not_analyzed","ignore_above": 100},
                "context":{"type":"string","store":"yes","index":"analyzed","analyzer": "ik_max_word","search_analyzer": "ik_max_word"},
                "keywords":{"type":"string","store":"yes","index":"analyzed","analyzer": "ik_max_word","search_analyzer": "ik_max_word"},
                "publishDate":{"type":"string","store":"yes","index":"not_analyzed"},
                "createTime":{"type":"string","store":"yes","index":"not_analyzed"},
                "modifyTime":{"type":"string","store":"yes","index":"not_analyzed"},
                "deleteTime":{"type":"string","store":"yes","index":"not_analyzed"},
                "url":{"type":"string","store":"yes","index":"not_analyzed"},
                "isDeleted":{"type":"string","store":"yes","index":"not_analyzed"}
            }
        }
    }
}

属性说明:

 

properties表示表的字段

  1. type字段类型,所有得字段都设置成了string,是因为在查询和编码过程中,有些类型不能很好的被转换,例如boolean
  2. store是否存储,属性有yes或者no,无论那种属性都会被存储,但如果设置成no,在查询的时候是无法用此属性作为查询项的,基于拓展和业务方便维护,建议使用yes
  3. index是否索引,属性有not_analyzed(分词不分析)、analyzed(分词分析)、no(不分析不分词)
  4. analyzer使用哪种分词器,在安装es的时候会自己安装分词器,例如IK分词器,在此指定分词的时候使用的是哪种分词器
  5. search_analyzer使用哪种分词器,但不是在入库的时候,而是在做查询的时候使用哪种分词器
  6. ignore_above对超过 ignore_above 的字符串,analyzer 不会进行处理;所以就不会索引起来。导致的结果就是最终搜索引擎搜索不到了。这个选项主要对 not_analyzed 字段有用,这些字段通常用来进行过滤、聚合和排序。而且这些字段都是结构化的,所以一般不会允许在这些字段中索引过长的项。
  7. format日期格式要求,例如设置为"yyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis" 

 

dynamic表示是否使用动态映射,属性有

  1. true默认值,动态添加字段
  2. false忽略新字段
  3. strict如果碰到陌生字段,抛出异常

 

settings表示设置

  1. num_of_shards设置分片数量,默认为5
  2. num_of_replicas设置副本数量,默认为1

 

  • 0
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值