Elasticsearch详解--API约定

1、Multiple Indices

_all
通配符风格
数学表达式
常用参数:
ignore_unavailable 是否忽略可用
allow_no_indices 当没有可用的时候是否正常
expand_wildcards 扩展通配符

创建例子:

curl -XPOST 192.168.11.130:9200/mutliindices1/test/1?pretty -d'{"name":"test1"}' 
curl -XPOST 192.168.11.130:9200/mutliindices1/test/2?pretty -d'{"name":"test1"}' 
curl -XPOST 192.168.11.130:9200/mutliindices2/test/1?pretty -d'{"name":"test1"}' 

使用数组形式:

curl -XPOST 192.168.11.130:9200/mutliindices1,mutliindices2/_search?pretty -d'{"query":{"match_all":{}}}' 

使用_all:

curl -XPOST 192.168.11.130:9200/_all/_search?pretty -d'{"query":{"match_all":{}}}' 

通配符

curl -XPOST 192.168.11.130:9200/mutliindices/_search?pretty -d'{"query":{"match_all":{}}}' 

去掉ban开头索引的数据,只搜索mutliindices的数据

curl -XPOST 192.168.11.130:9200/-ban,+mutliindices/_search?pretty -d'{"query":{"match_all":{}}}'

2、索引名中的数学日期支持

格式:(static_name{date_math_expr{date_foemat|time_zone}})

表达式表示的值
test-{now/d} test-2016.11.22
test-{now/M} test-2016.11.01
test-{now/M{YYYY.MM}} test-2016.11
test-{now/M-1M{YYYY.MM}} test-2016.10
test-{now/d{YYYY.MM.DD|+12:00}} test-2016.11.23
符号编码
< %3C
> %3E
/ %2F
{ %7B
} %7D
竖杠 %7C
+ %2B
: %3A

使用数字表达式创建索引:

curl -XPOST 192.168.11.130:9200/<test-\{now%2FM\}>/type/1?pretty -d'{"name":"test","age":"10"}'

使用数字表达式查询索引:

curl -XPOST 192.168.11.130:9200/<test-\{now%2FM\}>/_search?pretty -d'{"query":{"match_all":{}}}'

3、常用选项

返回数据格式化:?pretty ?format=yaml
带pretty说明以json的格式返回
format=yaml说明以树状形式格式返回
返回数据的易读:
?human=true
Date Math

示例              | 表示的值 
--------------   | --------------
now+1h           | 当前时间加一小时
now+1h+1m        | 当前时间加上一小时加一分钟
now+1h/d         | 当前时间加上一小时,向下舍入到最近的一天
2015-01-01|+1M/d | 2015-01-01加上一个月,向下舍入到最近一天

内容过滤:filter_path
扁平处理:flat_settings
参数类型
Boolean
Number
Date
Geo
返回结果--驼峰式
case=camelCase

4、基础URL的访问控制

 



 

 

posted @ 2017-12-26 23:22  归来似少年  阅读(448)  评论(0编辑  收藏  举报