elastic常用命令

列出所有索引:

  curl 'localhost:9200/_cat/indices?v'

 

# 删除索引
curl -XDELETE 'http://127.0.0.1:9200/res_center_1?pretty'

 

#获取映射

curl -XGET '10.124.134.206:9200/res_locking_number_his_1/_mapping?pretty' 

 

# 构建索引 指定映射

curl -XPUT 'http://127.0.0.1:9200/res_ce_1118?pretty=true' -d '
{
    "mappings" : {
        "_default_": {
            "_all": { "enabled":  false }
        },
        "res_number" : {
            "dynamic" : "strict",

            "properties" : {
             
                "PROVINCE_CODE" : {"type":"string","index":"not_analyzed"},
                "B_AREA_CODE" : {"type":"string","index":"not_analyzed"},
                "AREA_CODE" : {"type":"string","index":"not_analyzed"},
      
            }
        }
    }
}
'

字段类型有下面的:

Core Simple Field Typesedit

Elasticsearch supports the following simple field types:

  • String: string
  • Whole number: byteshortintegerlong
  • Floating-point: floatdouble
  • Boolean: boolean
  • Date: date

https://www.elastic.co/guide/en/elasticsearch/guide/current/mapping-intro.html#_viewing_the_mapping

# 别名
curl -XPUT 'http://127.0.0.1:9200/res_center_1/_alias/res_center?pretty=true'

# 检查字段映射
curl -XGET 'http://127.0.0.1:9200/res_center_1/_mapping/res_number?pretty=true'
curl -XGET 'http://127.0.0.1:9200/res_center/_mapping/res_number?pretty=true'

# 统计文档总数
curl -XGET 'http://127.0.0.1:9200/res_center/res_number/_search?pretty=true' -d '
{
    "from" : 0, "size" : 10
}
'

# type增加属性

 ##这个可以使用 

curl -XPUT 'http://127.0.0.1:9200/index/_mapping/type?pretty=true' -d '
{

  "properties": {
    "testField": {"type": "string","index":"not_analyzed"}
  }
}'

 

添加一个document:

curl -PUT 'http://127.0.0.1:9200/index/type/14800002' -d '{
   "DEVICE_NUMBER":"13701"
}'

 修改一个document

curl -XPOST 'http://locahost:9200/index/type/14800002/_update' -d '{
   "doc" : {
 "name" : "new_name"
   }
}

删除一个doc命令:

curl -XDELETE 'http://localhost:9200/index/type/13701019855'

  

  参考:https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值