es常用命令

查询命令

match

GET 索引名称/_search
{
  "query": {
    "match": {
      "字段名称": "xxxx"
    }
  }
}

terms

GET 索引名称/_search
{
  "query": {
    "terms": {
      "字段名称": [
        "8986112127603554579",
        "1585441384517906433"
      ]
    }
  }
}

wildcard

GET 索引名称/_search
{
  "query": {
    "wildcard": {
      "字段名称": {
        "value": "*1597474927485931522*"
      }
    }
  }
}

查询映射

GET 索引名称/_mapping
{}

删除命令

删除索引

DELETE 索引名称

根据查询条件删除数据

POST 索引名称/_delete_by_query?slices=auto&conflicts=proceed&wait_for_completion=false
{
  "query": {
    "terms": {
      "索引字段": [
        "xxxx1",
        "xxxxx2"
      ]
    }
  }
}

创建命令

创建索引

PUT 索引名称
{
  "mappings": {
    "properties": {
      "create_date": {
        "type": "date"
      },
      "customer_id": {
        "type": "long"
      },
      "customer_name": {
        "type": "keyword",
        "ignore_above": 256
      },
      "iccid": {
        "type": "keyword",
        "ignore_above": 256
      },
      "id": {
        "type": "keyword",
        "ignore_above": 256
      },
      "principal_id": {
        "type": "long"
      },
      "principal_name": {
        "type": "keyword",
        "ignore_above": 256
      },
      "real_usage": {
        "type": "float"
      },
      "type": {
        "type": "long"
      },
      "vanity_usage": {
        "type": "float"
      }
    }
  }
}

创建索引字段

PUT 索引名称/_mapping
{
  "properties": {
    "code": {
      "type": "text",
      "fields": {
        "keyword": {
          "type": "keyword",
          "ignore_above": 256
        }
      }
    }
  }
}

修改

修改关键字长度

PUT 索引名称/_mapping/_doc?include_type_name=true
{
“properties”: {
“字段名称”: {
“type”:“keyword”,
“ignore_above”:512
}
}
}

迁移数据

POST _reindex
{
  "source": {
    "index": "原索引"
  },
  "dest": {
    "index": "新索引"
  }
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值