lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ype Kingma <>
Subject Re: Range Query Sombody HELP please
Date Fri, 28 May 2004 07:43:55 GMT

On Friday 28 May 2004 05:54, Karthik N S wrote:

> Weh we do a search in SQL  using '*' we all know that the result would be
> total no of records in the table,but when  we want to get limit our record
> we apply  range between 2 specific row records [Which we call it as
> subsearch]
>    Similarly  on a indexed  record  I would like perform the same tecnique
> as above.

In case you need to reuse the limitation a filter is the way to go in Lucene.
However it seems to be better to get the range query working first.

>   In fact I was looking at the url u sent me in the last mail on using
> getRange Queries
>  and was working on the same

The query I gave uses two +'s prefixed to the query parts:

+search_word +(book:[100 TO 200])

Both query parts are required because of the +'s, ie. it works
as the AND operator in SQL. The TO operator queries the range
in the book field.

> and
> but witou results for the last 12 hrs.

You have probably seen a lot of different things that will be useful later.

> If u could spare a few minuts and please expalin or provide a simple  [
> full ] example using and
> over riding the  getRange() method .

The problem you'll probably run into is that Lucene does not
support numbers directly, you'll have to index them as strings,
eg. by prefixing zero's:

As Erik indicated:

You may have to reindex your data for this. In case you have a lot of data
consider setting up a test first.

Then in the getRangeQuery() method of your parser you'll need to prefix the queried
numbers in the same way. The example in the article is about date fields,
but the adaptation to numbers shouldn't be a problem.

When you override this in your query parser:
getRangeQuery(String field, Analyzer analyzer, String start, String end, boolean inclusive)
it will be called for the example query with  start = "100" and end = "200".

under Customizing query parser).

In the overriding method you can then call the super method with the
start and end prefixed with zero's as indicated in searching numerical fields
referred to above.

Have fun, you'll get it working,


> with regards
> Karthik
> -----Original Message-----
> From: Ype Kingma []
> Sent: Thursday, May 27, 2004 11:03 PM
> To:
> Subject: Re: Range Query Sombody HELP please
> On Thursday 27 May 2004 09:37, Karthik N S wrote:
> > Hi
> >    Lucene -Developer My main intention was
> >
> >  Search for an word hit  in a Unique Field  between  ranges     say
> > book100  - book 200  indexed numbers
> >  It's something like creating a SUBSEARCH  with in the SEARCHINDEX.
> Could you explain what you mean by subsearch?
> I suppose you might want to have a look at the various filter classes
> in the package.
> Regards,
> Ype
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

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

View raw message