ElasticSearch查询功能包括query和filter,使用RestAPI:_search方法进行查询。
Search
参数
- l Timeout:超时时间
- l From:等于offset
- l Size:返回长度。
- l Search_type:查询类型。
- l Query_cache:1.4之后的版本。是否使用查询缓存。
- l Terminate_after:1.4之后的版本。一个Shard可以在获取到多少条数据后,停止查询。
TODO:Shard query cache.
示例
1,查询匹配this is a test的document。
curl 'localhost:9200/idx/_search?pretty' -d '{
"query": {
"match" : {
"message" : "this is a test"
}
}
'}
2,指定需要返回的字段
curl 'localhost:9200/idx/_search?pretty' -d '{
"query": {
"match" : {
"message" : "this is a test"
},
"_source" : ["name"]
}
'}