开发者

Lucene trouble with indexing recurring events

I'm trying to come up with a way to query dates in Lucene. Basica开发者_如何学Pythonlly I have an event that has a start date, end date and can also occur regularly. The way I tried to go about it was to create an index field in Lucene that would list all the possible dates separated by a comma (or empty space would be enough, really) and than apply range search to it. The dates were indexed like this:

Event A starting on 31-10-09: "20091031"

Event B starting on 31-10-09 and lasting for 2 days: "20091031, 20091101, 20091102"

Event C recurring every Saturday for next 3 Saturdays: "20091031, 20091107, 20091114"

That however didn't work because if I was looking for events between 20091030 and 20091101, it should list events A, B and C but because B and C had some occurrences outside of the required range it did not find them.

Any idea how to solve it? Thanks


A possible way to do this is to create a separate document per each occurrence of every event. Both event B and C will then have three documents each, each of them having a date field and an event name field. A simple range search could then find the events.

A separate question is whether to do this in Lucene at all. Please see Search Engine versus DBMS for a discussion of related issues.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜