You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Shawn Konopinsky <sk...@blueprint.org> on 2004/12/03 19:12:10 UTC

Date Range Search throws IndexAccessException

It seems that when I run the query "datelastrevised:[0e130wml4 TO
0e2alh18o]" (where datelastrevised is a lucene date field) and the result
contains more than X results, that an IndexAccessException is thrown with no
error message. If I perform the same query on a smaller set of possible
matches, then it works fine.

I'm assuming that this must have something to do with how the date field
enumerates against the matches with 'by the second' granularity - and
thereby exceeding the maximum number of boolean clauses (please correct me
if I am wrong).

Is there some way to reduce the granularity of the search to 'by the day'
granularity? Otherwise is there some way to perform this query so that I can
retrieve the results without error?

Best,
Shawn.


---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org


RE: Date Range Search throws IndexAccessException

Posted by Chris Hostetter <ho...@fucit.org>.
: The problem with using a Filter is that I want to be able to merely generate
: a text query based on the range information instead of having to modify the
: core search module which basically receives text queries. If I understand
: correctly, the Filter would actually have to be created and passed into the
: search method.

I haven't acctually done this myself, but when I asked about RangeQuery vs
RangeFilter before, Erik pointed out that you can wrap a RangeFilter in
"FilteredQuery" so that you can still use the simpler search API (without
explicitly passing the filter).

If you're using the QueryParser that comes with Lucene, you can probably
subclass it and write you're own "getRangeQuery" to look like the code
below. (like i said, i haven't acctually tried this yet)

Truthfully, i wonder if it might not be a good idea to change the default
implimentation of getRangeQuery to be something like this?




  protected Query getRangeQuery(String field,
                                String part1,
                                String part2,
                                boolean inclusive) throws ParseException
  {
    try {
      DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, locale);
      df.setLenient(true);
      Date d1 = df.parse(part1);
      Date d2 = df.parse(part2);
      part1 = DateField.dateToString(d1);
      part2 = DateField.dateToString(d2);
    }
    catch (Exception e) { }

    return new FilteredQuery(
                          new TermQuery(new Term(field,"")), // match all docs
                          new RangeFilter(
                               new Term(field, part1),
                               new Term(field, part2),
                               inclusive,inclusive));
  }

---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org


RE: Date Range Search throws IndexAccessException

Posted by Shawn Konopinsky <sk...@blueprint.org>.
Thanks for the quick response Chris.

The problem with using a Filter is that I want to be able to merely generate
a text query based on the range information instead of having to modify the
core search module which basically receives text queries. If I understand
correctly, the Filter would actually have to be created and passed into the
search method.

Thoughts?

Shawn.

-----Original Message-----
From: hossman@hal.rescomp.berkeley.edu
[mailto:hossman@hal.rescomp.berkeley.edu]On Behalf Of Chris Hostetter
Sent: Friday, December 03, 2004 1:33 PM
To: Lucene Users List
Subject: Re: Date Range Search throws IndexAccessException



: I'm assuming that this must have something to do with how the date field
: enumerates against the matches with 'by the second' granularity - and
: thereby exceeding the maximum number of boolean clauses (please correct me
: if I am wrong).

I'm not so certain .. if you were really exceeding the max boolean clauses
limit, you should get a "TooManyClauses" exception

: Is there some way to reduce the granularity of the search to 'by the day'
: granularity? Otherwise is there some way to perform this query so that I
can
: retrieve the results without error?

take a look at the RangeFilter class i recently sent to the list (and is
now in cvs) ... in exchange for giving up scoring, it doesn't suffer any
of the Boolean Clause limitations of RangeQuery.



-Hoss


---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org


Re: Date Range Search throws IndexAccessException

Posted by Chris Hostetter <ho...@fucit.org>.
: I'm assuming that this must have something to do with how the date field
: enumerates against the matches with 'by the second' granularity - and
: thereby exceeding the maximum number of boolean clauses (please correct me
: if I am wrong).

I'm not so certain .. if you were really exceeding the max boolean clauses
limit, you should get a "TooManyClauses" exception

: Is there some way to reduce the granularity of the search to 'by the day'
: granularity? Otherwise is there some way to perform this query so that I can
: retrieve the results without error?

take a look at the RangeFilter class i recently sent to the list (and is
now in cvs) ... in exchange for giving up scoring, it doesn't suffer any
of the Boolean Clause limitations of RangeQuery.



-Hoss


---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org