lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Doron Cohen <>
Subject Re: Search Numerical Field
Date Fri, 28 Jul 2006 18:26:26 GMT

John john <> wrote on 28/07/2006 06:36:19:

> Hello,
>  I tried to add a field like that
>   field = new Field("number", "1",
>  so i should be indexed and to analyzed? my writer is
>  writer = new IndexWriter(INDEX_DIR, new StandardAnalyzer(), true);
>  but according to the javadoc it should be alright and searching
> with "number:1" should return resultats? Where i'm wrong?

Seems that should be working.

Having "number:1" as query text suggests that QueryParser.parse() was used
to get a query object, i.e. the query text is analyzed - which is
inconsistent with an UN_TOKENIZED field. Consider using TermQuery to avoid
tokenizing the query text:
    Query q = new TermQuery(new Term("number","1"));
However this cannot explain why no results are returned, since the string
"1" would generate the token "1" (well, "number:1") also with analysis.

Perhaps its the common problem of not closing indexWriter after adding the
doc or not re-opening searcher after closing the writer...

- Doron

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

View raw message