Hi Lucene users,

I am in the beginning of implementing a Lucene application which would
supposedly search through some log files.

One of the requirements is to return results between a time range. Let's
say these are two lines in a series of log files:
2015-02-08 00:02:06.852Z INFO...
...
2015-02-08 18:02:04.012Z INFO...

Now I need to search for these lines and return all the text in-between. I
was using this demo application to build an index:
http://lucene.apache.org/core/4_10_3/demo/src-html/org/apache/lucene/demo/IndexFiles.html

After that my first thought was using a term range query like this:
        TermRangeQuery query = TermRangeQuery.newStringRange("contents",
"2015-02-08 00:02:06.852Z", "2015-02-08 18:02:04.012Z", true, true);

But for some reason this didn't return any results.

Then I was Googling for a while how to solve this problem, but all the
datetime examples I found are searching based on a much simpler field.
Those examples usually use a field like this:
doc.add(new LongField("modified", file.lastModified(), Field.Store.NO));

So I was wondering, how can I index these log files to make a range query
work on them? Any ideas? Maybe my approach is completely wrong. I am still
new to Lucene so any help is appreciated.

Thank you.

Gergely Nagy

Reply via email to