ES elasticsearch
2016-12-27 15:01
309 查看
新增
PUT /megacorp/employee/2{
"first_name"
:
"Jane",
"last_name"
:
"Smith",
"age"
:
32,
"about"
:
"I like to collect rock albums",
"interests":
[
"music"
]}PUT
/megacorp/employee/3{
"first_name"
:
"Douglas",
"last_name"
:
"Fir",
"age"
:
35,
"about":
"I like to build cabinets",
"interests":
[
"forestry"
]}
PUT
/website/blog/123/_create
创建指定id的数据
{ ... }
查询
GET
/megacorp/employee/1
id查询GET
/megacorp/employee/_search
查询所有
GET
/megacorp/employee/_search?q=last_name:Smith
查询last_name
= Smith
GET
/megacorp/employee/_search
查询last_name = Smith
{
"query"
:
{
"match"
:
{
match
模糊搜索、match_phrase 全匹配
"last_name"
:
"Smith"
}
}}
GET
/megacorp/employee/_search
过滤查询
{
"query"
:
{
"filtered"
:
{
"filter"
:
{
"range"
:
{
"age"
:
{
"gt"
:
30
}
}
},
"query"
:
{
"match"
:
{
"last_name"
:
"smith"
}
}
}
}}GET
/_mget
组查询{
"docs"
:
[
{
"_index"
:
"website",
"_type"
:
"blog",
"_id"
:
2
},
{
"_index"
:
"website",
"_type"
:
"pageviews",
"_id"
:
1,
"_source":
"views"
}
]}
GET
/website/blog/_mget
组查询{
"ids"
:
[
"2",
"1"
]}
返回结果{
"_index"
:
"megacorp",
"_type"
:
"employee",
"_id"
:
"1",
"_version"
:
1,
"found"
:
true,
"_source"
:
{
"first_name"
:
"John",
"last_name"
:
"Smith",
"age"
:
25,
"about"
:
"I love to go rock climbing",
"interests":
[
"sports",
"music"
]
}}
GET
/_search 全部查询
Search all types in all indices
Search all types in the
Search all types in the
Search all types in any indices beginning with
beginning with
Search type
the
Search types
the
Search types
all indices
返回结果:
{
"hits"
:
{
"total"
:
14,
"hits"
:
[
{
"_index":
"us",
"_type":
"tweet",
"_id":
"7",
"_score":
1,
"_source":
{
"date":
"2014-09-17",
"name":
"John Smith",
"tweet":
"The Query DSL is really
powerful and flexible",
"user_id":
2
}
},
...
9
RESULTS REMOVED ...
],
"max_score"
:
1
},
"took"
:
4,
"_shards"
:
{
"failed"
:
0,
"successful"
:
10,
"total"
:
10
},
"timed_out"
:
false
}
GET
/_search?size=5
查出五个GET
/_search?size=5&from=5
从第五个开始查出五个GET
/_search?size=5&from=10
从第十个开始查出五个
PUT /megacorp/employee/2{
"first_name"
:
"Jane",
"last_name"
:
"Smith",
"age"
:
32,
"about"
:
"I like to collect rock albums",
"interests":
[
"music"
]}PUT
/megacorp/employee/3{
"first_name"
:
"Douglas",
"last_name"
:
"Fir",
"age"
:
35,
"about":
"I like to build cabinets",
"interests":
[
"forestry"
]}
PUT
/website/blog/123/_create
创建指定id的数据
{ ... }
查询
GET
/megacorp/employee/1
id查询GET
/megacorp/employee/_search
查询所有
GET
/megacorp/employee/_search?q=last_name:Smith
查询last_name
= Smith
GET
/megacorp/employee/_search
查询last_name = Smith
{
"query"
:
{
"match"
:
{
match
模糊搜索、match_phrase 全匹配
"last_name"
:
"Smith"
}
}}
GET
/megacorp/employee/_search
过滤查询
{
"query"
:
{
"filtered"
:
{
"filter"
:
{
"range"
:
{
"age"
:
{
"gt"
:
30
}
}
},
"query"
:
{
"match"
:
{
"last_name"
:
"smith"
}
}
}
}}GET
/_mget
组查询{
"docs"
:
[
{
"_index"
:
"website",
"_type"
:
"blog",
"_id"
:
2
},
{
"_index"
:
"website",
"_type"
:
"pageviews",
"_id"
:
1,
"_source":
"views"
}
]}
GET
/website/blog/_mget
组查询{
"ids"
:
[
"2",
"1"
]}
返回结果{
"_index"
:
"megacorp",
"_type"
:
"employee",
"_id"
:
"1",
"_version"
:
1,
"found"
:
true,
"_source"
:
{
"first_name"
:
"John",
"last_name"
:
"Smith",
"age"
:
25,
"about"
:
"I love to go rock climbing",
"interests":
[
"sports",
"music"
]
}}
GET
/_search 全部查询
/_search
Search all types in all indices
/gb/_search
Search all types in the
gbindex
/gb,us/_search
Search all types in the
gband
usindices
/g*,u*/_search
Search all types in any indices beginning with
gor
beginning with
u
/gb/user/_search
Search type
userin
the
gbindex
/gb,us/user,tweet/_search
Search types
userand
tweetin
the
gband
usindices
/_all/user,tweet/_search
Search types
userand
tweetin
all indices
返回结果:
{
"hits"
:
{
"total"
:
14,
"hits"
:
[
{
"_index":
"us",
"_type":
"tweet",
"_id":
"7",
"_score":
1,
"_source":
{
"date":
"2014-09-17",
"name":
"John Smith",
"tweet":
"The Query DSL is really
powerful and flexible",
"user_id":
2
}
},
...
9
RESULTS REMOVED ...
],
"max_score"
:
1
},
"took"
:
4,
"_shards"
:
{
"failed"
:
0,
"successful"
:
10,
"total"
:
10
},
"timed_out"
:
false
}
GET
/_search?size=5
查出五个GET
/_search?size=5&from=5
从第五个开始查出五个GET
/_search?size=5&from=10
从第十个开始查出五个
相关文章推荐
- ElasticSearch restful api 的客户端PostMan实现对ES的增删改查
- hanlp for elasticsearch(基于hanlp的es分词插件)
- 使用Spring Data Elasticsearch操作es(1)--环境搭建
- Elasticsearch For Apache Hadoop (ES-Hadoop)最新介绍
- Elasticsearch range 查询 ES 5.x TODO
- ELK研究(一):elasticsearch java api接口操作ES集群 ---TransportClient的使用介绍 bulk批量提交数据
- ElasticSearch+ElasticGeo+Geoserver发布ES地理数据
- Elasticsearch es常用命令
- ES权威指南[官方文档学习笔记]-5---talking to elasticsearch
- ElasticSearch之——Java操作ES实例(基于ES-2.3.0)
- hanlp for elasticsearch(基于hanlp的es分词插件)
- ES(6): access elasticsearch via curl
- ELK6.2.2(elasticsearch+logstash+kibana)开源日志分析平台搭建(一):es简单搭建
- ES之八:elasticsearch2.x下的JAVA API示例
- spark连接es的问题java.lang.ClassNotFoundException:org.elasticsearch.client.transport.NoNodeAvailableExcep
- ELK研究(一):elasticsearch java api接口操作ES集群 ---TransportClient的使用介绍 bulk批量提交数据
- elasticsearch系列一:elasticsearch(ES简介、安装&配置、集成Ikanalyzer)
- elasticsearch+logstash之间传输效率以及es-sql查询效率简单测试
- Elasticsearch基础教程ES
- ES使用org.elasticsearch.client.transport.NoNodeAvailableException: No node available 错误解决方法