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 Xin Herbert Wu <xi...@pathf.com> on 2006/02/17 22:19:58 UTC

wildcard search constraints?

Hi, 

I have a lucene index library field "slug" which has a string value
"abc-nws-hurr29". 

When using these settings:

-  Use QueryParser 

-  StandardAnalyzer

 

I have some strange behaviors:

(1) The field query slug:abc*hurr2* works only if the field type is
"Keyword". The query fails if the type is "Text".

(2) On the other hand, query slug:abc-nws-hurr29 only works if the field
type is "Text" and fails if the type is "Keyword"

 

I prefer to use StandardAnalyzer for all the basic searches so that I can
construct complex field query involved many different types of fields, but
it seems it has some limitations on wildcard searches. 

Do I have to use other Analyzer in order to have a correct wildcard search
on different types of fields?

 

I use lucene1.4.3 on java 5 and the behavior is verified by luke-0.6 tool. 

 

Any help is greatly appreciated!

 

-Xin


Re: wildcard search constraints?

Posted by Chris Hostetter <ho...@fucit.org>.
: I have some strange behaviors:
:
: (1) The field query slug:abc*hurr2* works only if the field type is
: "Keyword". The query fails if the type is "Text".
:
: (2) On the other hand, query slug:abc-nws-hurr29 only works if the field
: type is "Text" and fails if the type is "Keyword"

I think the problems you are seeing can be explain thusly:

  1) field type Text results in your analyzer (in this case
StandardAnalyzer) splitting the text on hyphens, or maybe it's just
pulling the numbers off, i don't acctually remember exactly what
StandardAnalyzer does, but when looking at your terms in luke you probaly
won't see "abc-nws-hurr29"

  2) regardless of how you index yourfield, QueryParser is going to pass
any text you give it to the analyzer (i'm guessing that again you are
using StanardAnalyzer in your QueryParser) which will again split on
hyphens (or maybe numbers) and this won't match your Keyword field (which
contains the literal value "abc-nws-hurr29"

: Do I have to use other Analyzer in order to have a correct wildcard search
: on different types of fields?

The tricky thing about wildcard searches in QueryParser is that QP can't
analyze your search input because of the wildcard tokens, so you have to
be very carefull in picking which analyzer you use for the fields you want
to do wildcard searching on.

Make sure you take a look at the PerFieldAnalyzerWrapper ... it will let
you use different analyzers for different fields.



-Hoss


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