lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Karsten F." <>
Subject Re: Searching substring starting at a fixed position
Date Thu, 11 Sep 2008 12:10:52 GMT

Hi Luther,

your question:
"Is there a way to ask Lucene to search starting from a fixed position?"

the anwer: no, not by standard search.

But you don't want to use your field for scoring. So this is a field to
filter results.
you could easily change RangeFilter for this purpose but the new filter
would have to read all tokes of this field(which is slow).
So you should cache the filter with CachingWrapperFilter (at least the "most
wanted" periods).

if you have a lot of changes in (only) this field you should consider to
build a lucene Filter by your own without the help of lucene index (e.g.
direct use of bitsets or a database).
if you don"t have a lot of changes but a lot of different periods to search
for, you should change your datamodel.
Because you easly can use lucene with 1 field and 365 different tokens
(20080101, 20080102, ...20081231).

Best regards 

luther blisset wrote:
> hi folks,
> I'm new to Lucene and I'm looking for a way to search a substring that
> starts at a fixed position.
> It isn't a classical substring search because it's a bit weird.
> I indexed a field that represents the avability of a room in a hostal
> during 1 year.
> The field is composed by 365 digits and each digit represents 1 day and it
> can be set at 0 (available) or 1 (not available). Thus a string like this:
> 110001111...(continues with ones until the position 365)
> means that the hostal is available from 3rd until 5th of January.
> And now the problem...
> Suppose that I want to search if an hostal is available from 3rd to 5th of
> January...
> I'd have to use wildcards and search a string like this:
> ??000????...(continues with ? until the position 365)
> I think this way is not a good one and is too bad for the application
> perfomance.
> Is there a way to ask Lucene to search starting from a fixed position?
> For instance, regard to the example above, could I search a 000 starting
> to search at the third position?
> I hope all was clear and you can help me because I've no idea how to solve
> the problem.
> Thanks a lot!
> Luther

View this message in context:
Sent from the Lucene - Java Users mailing list archive at

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message