Permalink
Browse files

Add BEFORE and AFTER timestamp searches

  • Loading branch information...
johnl committed Sep 5, 2011
1 parent 0e24c00 commit 88050108d120218abde52b5b5b42178528045de1
Showing with 12 additions and 0 deletions.
  1. +12 −0 rsyslog-solr-search
View
@@ -39,6 +39,7 @@ limit = (ENV["LIMIT"] || 15).to_i
page = (ENV["PAGE"] || 1).to_i
offset = (page - 1) * limit
sort = ENV["SORT"]
+
if ENV["AT"]
at = Time.parse(ENV["AT"])
timespan = (ENV["TIMESPAN"] || 120).to_i
@@ -47,6 +48,17 @@ if ENV["AT"]
query = "+(timestamp:[#{from} TO #{to}]) AND (#{query})"
sort = "time" unless sort
end
+
+if ENV["BEFORE"]
+ before = Time.parse(ENV["BEFORE"])
+ query = "+(timestamp:[* TO #{before}]) AND (#{query})"
+end
+
+if ENV["AFTER"]
+ after = Time.parse(ENV["AFTER"])
+ query = "+(timestamp:[#{after} TO *]) AND (#{query})"
+end
+
sort = (sort == "time") ? "timestamp desc" : "score desc, timestamp desc"
def search(query, options = {})

0 comments on commit 8805010

Please sign in to comment.