lucene-java-user mailing list archives

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

John john <ze_barbary@yahoo.fr> wrote on 28/07/2006 06:36:19:

> Hello,
>
>  I tried to add a field like that
>   field = new Field("number", "1",
Field.Store.YES,Field.Index.UN_TOKENIZED);
>
>  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: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message