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 CM Wong <cm...@yahoo.com> on 2009/04/28 14:26:15 UTC

NOT_ANALYZED field

Hi,

In my simple program I have an ID field which is NON_ANALYZED. I find that if
the field contains only numeric characters (e.g. id="00023"), I can
successsfully search for the doc. (search for "id:00023")

But if the field contains non-numeric characates (e.g. id="nJK00023") then the
search returns nothing. (search for "id:nJK00023")

Is there anything wrong with my program?

Regards,
CM


Send instant messages to your online friends http://uk.messenger.yahoo.com 

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


Re: NOT_ANALYZED field

Posted by Erick Erickson <er...@gmail.com>.
Well, you haven't shown us your program, so it's hard to tell<G>....

But my first uninformed guess would be that the case of your search
doesn't exactly match the case you indexed when you add letters
to your IDs.

We need to see the search code particularly, including the
analyzers you use (a snippet would do to start). The index code
would be useful too.

Best
Erick

On Tue, Apr 28, 2009 at 8:26 AM, CM Wong <cm...@yahoo.com> wrote:

>
> Hi,
>
> In my simple program I have an ID field which is NON_ANALYZED. I find that
> if
> the field contains only numeric characters (e.g. id="00023"), I can
> successsfully search for the doc. (search for "id:00023")
>
> But if the field contains non-numeric characates (e.g. id="nJK00023") then
> the
> search returns nothing. (search for "id:nJK00023")
>
> Is there anything wrong with my program?
>
> Regards,
> CM
>
>
> Send instant messages to your online friends http://uk.messenger.yahoo.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

RE: NOT_ANALYZED field

Posted by CM Wong <cm...@yahoo.com>.
Thanks a lot. I am now indexing my id in lowercase and my problem is solved.

Regards,
CM


--- Uwe Schindler <uw...@thetaphi.de> wrote:

> That is normal. Fields that are not analyzed are indexed as single tokens.
> The anaylzer does not only tokenize the text, it also transforms it (e.g. to
> lower case). If you enter your search using the query parser, the entered
> search terms are analyzed! And for full text engines, the analyzer for
> querying and searching must be the same. So it is normal, that your search
> will not return results (in your example, it would work, if the id would be
> indexed in lower case, because the analyzer on top of your query string
> lowercases the term).
> 
> So not-analyzed fields should be directly queried using TermQuery(....),
> e.g. to find the document with an untokenized id.
> 
> If you really want to use query parser, think about PerFieldAnalyzerWrapper
> using KeywordTokenizer for the id field.
> 
> Uwe
> 
> -----
> Uwe Schindler
> H.-H.-Meier-Allee 63, D-28213 Bremen
> http://www.thetaphi.de
> eMail: uwe@thetaphi.de
> 
> 
> > -----Original Message-----
> > From: CM Wong [mailto:cmwong2@yahoo.com]
> > Sent: Tuesday, April 28, 2009 2:26 PM
> > To: java-user@lucene.apache.org
> > Subject: NOT_ANALYZED field
> > 
> > 
> > Hi,
> > 
> > In my simple program I have an ID field which is NON_ANALYZED. I find that
> > if
> > the field contains only numeric characters (e.g. id="00023"), I can
> > successsfully search for the doc. (search for "id:00023")
> > 
> > But if the field contains non-numeric characates (e.g. id="nJK00023") then
> > the
> > search returns nothing. (search for "id:nJK00023")
> > 
> > Is there anything wrong with my program?
> > 
> > Regards,
> > CM


Send instant messages to your online friends http://uk.messenger.yahoo.com 

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


RE: NOT_ANALYZED field

Posted by Uwe Schindler <uw...@thetaphi.de>.
That is normal. Fields that are not analyzed are indexed as single tokens.
The anaylzer does not only tokenize the text, it also transforms it (e.g. to
lower case). If you enter your search using the query parser, the entered
search terms are analyzed! And for full text engines, the analyzer for
querying and searching must be the same. So it is normal, that your search
will not return results (in your example, it would work, if the id would be
indexed in lower case, because the analyzer on top of your query string
lowercases the term).

So not-analyzed fields should be directly queried using TermQuery(....),
e.g. to find the document with an untokenized id.

If you really want to use query parser, think about PerFieldAnalyzerWrapper
using KeywordTokenizer for the id field.

Uwe

-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de
eMail: uwe@thetaphi.de


> -----Original Message-----
> From: CM Wong [mailto:cmwong2@yahoo.com]
> Sent: Tuesday, April 28, 2009 2:26 PM
> To: java-user@lucene.apache.org
> Subject: NOT_ANALYZED field
> 
> 
> Hi,
> 
> In my simple program I have an ID field which is NON_ANALYZED. I find that
> if
> the field contains only numeric characters (e.g. id="00023"), I can
> successsfully search for the doc. (search for "id:00023")
> 
> But if the field contains non-numeric characates (e.g. id="nJK00023") then
> the
> search returns nothing. (search for "id:nJK00023")
> 
> Is there anything wrong with my program?
> 
> Regards,
> CM
> 
> 
> Send instant messages to your online friends http://uk.messenger.yahoo.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org



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