Mailing List Archive

DateFilter and NullPointerException
I'm having a problem when using Query and DateFilter for a search. If I
create DateFilter with DateFilter.After with current time&date as parameter,
then I get NullPointerException when executing search
(Searcher.search(Query, DateFilter)). Had anyone experienced something like
that? If I set time just a bit in past, it returns empty hits which is how
it should behave all the time.

code snipet:
// I have java files as documents, consisting of content
(Field.Text()) and modified (Field.Keyword())
Query q = new WildcardQuery(new Term("content", "packag*"));
DateFilter df = DateFilter.After("modified",
Calendar.getInstance().getTime());
Searcher searcher = new IndexSearcher(path);
Hits hits = searcher.search(q, df); // line 66

exception:
Exception in thread "main" java.lang.NullPointerException
at org.apache.lucene.search.DateFilter.bits(Unknown Source)
at org.apache.lucene.search.IndexSearcher.search(Unknown Source)
at org.apache.lucene.search.Hits.getMoreDocs(Unknown Source)
at org.apache.lucene.search.Hits.<init>(Unknown Source)
at org.apache.lucene.search.Searcher.search(Unknown Source)
at Search.main(Search.java:66)

Regards,
Uros.
Re: DateFilter and NullPointerException [ In reply to ]
Hm, do you know which line in DateFilter.java this NPE comes from?
Could you try compiling Lucene with the -g switch so that we can see
the line numbers in the exception stack trace?

If you want you can also submit a bug report at
http://nagoya.apache.org/bugzilla/

Thanks,
Otis

--- Uro¹_Jurgliè <jurglic@parsek.net> wrote:
> I'm having a problem when using Query and DateFilter for a search. If
> I
> create DateFilter with DateFilter.After with current time&date as
> parameter,
> then I get NullPointerException when executing search
> (Searcher.search(Query, DateFilter)). Had anyone experienced
> something like
> that? If I set time just a bit in past, it returns empty hits which
> is how
> it should behave all the time.
>
> code snipet:
> // I have java files as documents, consisting of content
> (Field.Text()) and modified (Field.Keyword())
> Query q = new WildcardQuery(new Term("content", "packag*"));
> DateFilter df = DateFilter.After("modified",
> Calendar.getInstance().getTime());
> Searcher searcher = new IndexSearcher(path);
> Hits hits = searcher.search(q, df); // line 66
>
> exception:
> Exception in thread "main" java.lang.NullPointerException
> at org.apache.lucene.search.DateFilter.bits(Unknown Source)
> at org.apache.lucene.search.IndexSearcher.search(Unknown
> Source)
> at org.apache.lucene.search.Hits.getMoreDocs(Unknown Source)
> at org.apache.lucene.search.Hits.<init>(Unknown Source)
> at org.apache.lucene.search.Searcher.search(Unknown Source)
> at Search.main(Search.java:66)
>
> Regards,
> Uros.
>


__________________________________________________
Do You Yahoo!?
Check out Yahoo! Shopping and Yahoo! Auctions for all of
your unique holiday gifts! Buy at http://shopping.yahoo.com
or bid at http://auctions.yahoo.com

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