elasticsearch搜索之范围维度 Star.hou原创

来源:互联网 发布:逗猫软件 编辑:程序博客网 时间:2024/05/20 03:41

elasticsearch搜索之范围 Star.hou的红楼一梦

1、所有的搜索API都可以跨多个类型使用

比如:只写入index,而type不写。这么说,可以在本index里所有type进行搜索。如下

$ curl -XGET 'http://localhost:9200/twitter/_search?q=user:kimchy'

2、多类型范围搜索
比如:只写入index,而type写入多个,这么在一个index库里,可以在指定的多个type里进行搜索。如下

$ curl -XGET 'http://localhost:9200/twitter/tweet,user/_search?q=user:kimchy'

3、跨多个索引搜索
比如:如下写入多个指定index范围,或者用_all标示全部index范围。

$ curl -XGET 'http://localhost:9200/kimchy,elasticsearch/tweet/_search?q=tag:wow'
$ curl -XGET 'http://localhost:9200/_all/tweet/_search?q=tag:wow'

4、跨所有可用索引和所有可用类型的推特
搜索范围:包含了所有index,所有type。如下

$ curl -XGET 'http://localhost:9200/_search?q=tag:wow'

以上在ES里搜索维度我认为如果在mysql里可以对比理解 :
index 索引 —>(mysql数据库:database)
type 类型—–>(mysql表:table)
应用:通过ES的index、type组合范围进行搜索,可以满足业务条件下各种全文搜索。

0 0
原创粉丝点击