Elasticsearch 权威指南
  • Elasticsearch 权威指南
  • 入门
    • 初识
    • 安装
    • API
    • 文档
    • 索引
    • 搜索
    • 汇总
    • 小结
    • 分布式
    • 本章总结
  • 分布式集群
    • 空集群
    • 集群健康
    • 添加索引
    • 容错移转
    • 横向扩展
    • 扩展
    • 故障恢复
  • 数据
    • 文档
    • 索引
    • Get
    • 存在
    • 更新
    • 创建
    • 删除
    • 版本控制
    • 局部更新
    • Mget
    • Bulk
    • 总结
  • 分布式文档存储
    • 路由
    • 主从互通
    • 创建索引删除
    • 获取
    • 局部更新
    • 批量请求
    • 批量格式
  • 搜索
    • 空白搜索
    • 多索引多类型
    • 分页
    • 查询语句
  • 映射与统计
    • Exact_vs_full_text
    • Inverted_index
    • Analysis
    • Mapping
    • Complex_datatypes
Powered by GitBook
On this page

Was this helpful?

  1. 数据

存在

如果确实想检查一下文档是否存在,你可以试用HEAD来替代GET方法,这样就是会返回HTTP头文件:

curl -i -XHEAD /website/blog/123

如果文档存在,Elasticsearch将会返回200 OK的状态码:

HTTP/1.1 200 OK
Content-Type: text/plain; charset=UTF-8
Content-Length: 0

如果不存在将会返回404 Not Found状态码:

curl -i -XHEAD /website/blog/124
HTTP/1.1 404 Not Found
Content-Type: text/plain; charset=UTF-8
Content-Length: 0

当然,这个反馈只代表了你查询的那一刻文档不存在,但是不代表几毫秒后它不存在,很可能与此同时,另一个进程正在创建文档。

PreviousGetNext更新

Last updated 5 years ago

Was this helpful?