12月12日北京OSC源创会 —— 开源技术的年终盛典 ?
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。
1 2 3 4 5 6 7 | curl 'localhost:9200/idx/_search?pretty' -d '{
"query" : {
"match" : {
"message" : "this is a test"
}
}
'}
|
2,指定需要返回的字段
1 2 3 4 5 6 7 8 | curl 'localhost:9200/idx/_search?pretty' -d '{
"query" : {
"match" : {
"message" : "this is a test"
},
"_source" : [ "name" ]
}
'}
|
12月12日北京OSC源创会 —— 开源技术的年终盛典 ?
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。
1 2 3 4 5 6 7 | curl 'localhost:9200/idx/_search?pretty' -d '{
"query" : {
"match" : {
"message" : "this is a test"
}
}
'}
|
2,指定需要返回的字段
1 2 3 4 5 6 7 8 | curl 'localhost:9200/idx/_search?pretty' -d '{
"query" : {
"match" : {
"message" : "this is a test"
},
"_source" : [ "name" ]
}
'}
|
|