mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 22:57:16 -04:00
- Add offset and limit paramters to SearchRequest
This commit is contained in:
parent
788781bf22
commit
35c8fe2670
2 changed files with 15 additions and 1 deletions
|
@ -15,6 +15,8 @@ module LogStash; module Net; module Messages
|
|||
# Message attributes
|
||||
hashbind :query, "/args/query"
|
||||
hashbind :log_type, "/args/log_type"
|
||||
hashbind :offset, "/args/offset"
|
||||
hashbind :limit, "/args/limit"
|
||||
end # class SearchRequest
|
||||
|
||||
class SearchResponse < ResponseMessage
|
||||
|
|
|
@ -67,13 +67,25 @@ module LogStash; module Net; module Servers
|
|||
:or_default => false)
|
||||
query = qp.parse(request.query)
|
||||
results = []
|
||||
offset = 0
|
||||
offset = (request.offset or 0)
|
||||
total = request.limit
|
||||
limit = 50
|
||||
|
||||
done = false
|
||||
while !done
|
||||
done = true
|
||||
puts "Searching..."
|
||||
|
||||
if total
|
||||
limit = [total, limit].min
|
||||
total -= limit
|
||||
|
||||
if limit <= 0
|
||||
done = true
|
||||
next
|
||||
end
|
||||
end
|
||||
|
||||
search.search_each(query, :limit => limit, :offset => offset,
|
||||
:sort => "@DATE") do |docid, score|
|
||||
done = false
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue