ES学习摘要 - 5. API Conventions

5.1 Multiple Indices

在REST接口需要指定index参数的地方,都可以同时指定多个索引,比如test1,test2,test3,_all,test*,te*t。还可以表达excluce语义,如test*,-test3。

所有索引类API都支持以下几个参数:

ignore_unavailable:忽略指定的索引不存在或者已close

allow_no_indices:忽略带通配符的index参数未匹配任何实际索引

expand_wildcards:确定通配符是否需要扩展为打开索引或闭合索引或两者。

5.2 Date math support in index names

可以通过日期表达式指定一组index name满足特定日期格式的索引

<static_name{date_math_expr{date_format|time_zone}}>

5.3 Common options

以下参数可以添加到所有REST API上:

Pretty Results

添加?pretty=true返回的JSON数据会经过格式化

Human readable output

添加?human=false,返回的数字/时间会以更可读的形式展示,如"1kb", "1h"

Date Math

所有接受格式化日期的地方,都可以接受date math。日期可以为now,或者一个具体的日期字符串以||结尾,接着一下表达式:

+1h 往后一小时

-1d 往前一天

/d round down to the nearest day

例子:

now+1h

2001.02.01||+1M/d 结果为2001-03-01 00:00:00

Response Filtering

通过filter_path可以控制返回的JSON中包含的fields:

filter_path=took,hits.hits._id

filter_path=metadata.indices.*.stat* *替代任意field,或者field name的一部分

filter_path=routing_table.indices.**.state **替代多级fields

filter_path=-_shards -用来剔除

转载于:https://my.oschina.net/zhuhui/blog/3079958

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值