es查询字段更新记录_ES查看分词结果|es字段类型修改|ES常用命令

查看分词结果

//query结构

GET /{index}/{type}/{_id}/_termvectors?fields={field_name}

//示例

GET /youdu_test/books/41286/_termvectors?fields=book_name

sort脚本排序

"sort": {

"_script": {

"type": "string",

"script":{

"inline": "doc['book_author']"

},

"order":"asc"

}

}

修改mapping中的字段类型

此处示例index为:youdu(已存在) youdu_test(为未创建)

以下请求的header都为:Content-Type:application/json

新建一个替代index(youdu_test)

获取youdu的mapping

//query结构

GET $domain+$port/{index}/{type}/_mapping

//示例

GET http://192.168.0.202:9200/youdu/books/_mapping

截取{type}部分json留做后面建立youdu_test的mapping使用,如

{

"youdu": {

"mappings": {

"books": {

"properties": {

"auto_gather": {

"type": "keyword"

},

}

}

}

}

}

创建youdu_test的mapping

将上面截取的{type}部分json去传入和修改

//query结构

PUT $domain+$port/{index}/{type}/_mapping

{

//json串

}

//示例,更改auto_gather字段的类型为text

PUT http://192.168.0.202:9200/youdu_test/books/_mapping

{

"books": {

"properties": {

"auto_gather": {

"type": "text"

},

}

}

}

同步youdu的数据到youdu_test

//query结构

POST $domain+$port/_reindex

//示例

POST http://192.168.0.202:9200/_reindex

{

"source": {

"index": "youdu"

},

"dest": {

"index": "youdu_test"

}

}

获取所有别名

GET _cat/aliases?v

获取_index_name模式内所有指定别名为_alias_name模式的index

GET /_index_name/_alias|_aliases/_alias_name

_alias和_aliases的区别为若指定为_aliases在查询时若_index未指定满足要求的别名在返回结果中是否包含但aliasese属性为空, 使用_alias时不包含该index

设置别名

PUT /_index_name/_alias/_alias_name

删除别名

DELETE /_index_name/_alias/_alias_name

持续更新 +1

为已有index/type添加字段并设置默认值

//1.先插入字段

PUT /{index}/_mapping/{type}

{

"properties": {

"m_part_limit":{

"type": "long"

}

}

}

//然后设置默认值

POST /{index}/_update_by_query

{

"script": {

"lang": "painless",

"inline": "if (ctx._source.m_part_limit== null) {ctx._source.m_part_limit= 15}"

}

}

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值