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 Ueli Kistler <Ue...@trivadis.com> on 2009/08/13 14:19:25 UTC

Wildcard search fails

Hello,

 

We're experiencing a problem using Lucene 2.4.1 and Compass 2.1.4 using
wildcard search.

Attribute values containing slashes can be searched using the full word,
but not using wildcards. We already tried different analyzers with the
same result.

Slash isn't mentioned as a stop word only backslash also.

 

Example : Searching < RZ/G/17 > and also < RZ/G/22 > succeed, but <
RZ/G/* > , < RZ/G* > or < RZ/G/ ?? > don't.

 

Any ideas why wildcard search doesn't work?

 

Thanks,

Ueli Kistler

 


AW: AW: AW: Wildcard search fails

Posted by Ueli Kistler <Ue...@trivadis.com>.
Hello,

using PatternAnalyzer solved the problem as well, using a whitespace pattern.
There's lowercase support as well (see http://lucene.apache.org/java/2_2_0/api/org/apache/lucene/index/memory/PatternAnalyzer.html)

Many thanks.

Regards,
Ueli Kistler

-----Ursprüngliche Nachricht-----
Von: AHMET ARSLAN [mailto:iorixxx@yahoo.com] 
Gesendet: Freitag, 14. August 2009 12:56
An: java-user@lucene.apache.org
Betreff: Re: AW: AW: Wildcard search fails

> Noticed that in Luke... is there any existing analyzer around that 
> supports case-insensitive search and recognizes "RZ/G/17" as one token? 

As far as I know there is no built-in analyzer that uses whitespace tokenizer and lowercase filter together. But it is easy to cast tokenizer and token filters to create a new analyzer. You said that you were using SnowballAnalyzer, right? Just replace tokenizer from standard to whitespace. Edit SnowballAnalyzer.java :

public TokenStream tokenStream(String fieldName, Reader reader) {
    TokenStream result = new WhitespaceTokenizer(reader);
    result = new LowerCaseFilter(result);
    if (stopSet != null)
      result = new StopFilter(result, stopSet);
    result = new SnowballFilter(result, name);
    return result;
  }

By changing this method you can create custom analyzers. If you do not want stemming just erase the line that contains SnowballFilter, etc. Since you have lowercasefilter in your analyzer, your wildcard queries should be lowercased. Alternatively you can set setLowercaseExpandedTerms(true) of your QueryParser.


      

---------------------------------------------------------------------
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


Re: AW: AW: Wildcard search fails

Posted by AHMET ARSLAN <io...@yahoo.com>.
> Noticed that in Luke... is there any existing analyzer around that 
> supports case-insensitive search and recognizes "RZ/G/17" as one token? 

As far as I know there is no built-in analyzer that uses whitespace tokenizer and lowercase filter together. But it is easy to cast tokenizer and token filters to create a new analyzer. You said that you were using SnowballAnalyzer, right? Just replace tokenizer from standard to whitespace. Edit SnowballAnalyzer.java :

public TokenStream tokenStream(String fieldName, Reader reader) {
    TokenStream result = new WhitespaceTokenizer(reader);
    result = new LowerCaseFilter(result);
    if (stopSet != null)
      result = new StopFilter(result, stopSet);
    result = new SnowballFilter(result, name);
    return result;
  }

By changing this method you can create custom analyzers. If you do not want stemming just erase the line that contains SnowballFilter, etc. Since you have lowercasefilter in your analyzer, your wildcard queries should be lowercased. Alternatively you can set setLowercaseExpandedTerms(true) of your QueryParser.


      

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


AW: AW: Wildcard search fails

Posted by Ueli Kistler <Ue...@trivadis.com>.
Noticed that in Luke... is there any existing analyzer around that supports case-insensitive search and recognizes "RZ/G/17" as one token? 

-----Ursprüngliche Nachricht-----
Von: AHMET ARSLAN [mailto:iorixxx@yahoo.com] 
Gesendet: Donnerstag, 13. August 2009 22:52
An: java-user@lucene.apache.org
Betreff: Re: AW: Wildcard search fails

> we used different analyzers and regenerated the index each
> time with the same results...used Luke each time already.
> Currently we're using SnowBall and Luke can't find any
> documents using the supplied query examples below (in
> zzz-all).
> 
> Same happened using StandardAnalyzer (for both, indexing
> and search).
> Using Luke with StandardAnalyzer set, searching for
> "rz/g/*" results in a query for zzz-all:rz/g/* but with no results.

StandardTokenizer produces two tokens ('rz' and  'g/17') from 'RZ/G/17'.
That's why "rz/g/*" is not matching. WhitespaceTokenizer or WhitespaceAnalyazer will recognize 'RZ/G/17' as one token.
Then you the query "RZ/G/*" will return 'RZ/G/17'. Also wildcard queries are not analyzed (tokenize, lowercase, stem, etc). 


      

---------------------------------------------------------------------
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


Re: AW: Wildcard search fails

Posted by AHMET ARSLAN <io...@yahoo.com>.
> we used different analyzers and regenerated the index each
> time with the same results...used Luke each time already.
> Currently we're using SnowBall and Luke can't find any
> documents using the supplied query examples below (in
> zzz-all).
> 
> Same happened using StandardAnalyzer (for both, indexing
> and search).
> Using Luke with StandardAnalyzer set, searching for
> "rz/g/*" results in a query for zzz-all:rz/g/* but with no results.

StandardTokenizer produces two tokens ('rz' and  'g/17') from 'RZ/G/17'.
That's why "rz/g/*" is not matching. WhitespaceTokenizer or WhitespaceAnalyazer will recognize 'RZ/G/17' as one token.
Then you the query "RZ/G/*" will return 'RZ/G/17'. Also wildcard queries are not analyzed (tokenize, lowercase, stem, etc). 


      

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


AW: Wildcard search fails

Posted by Ueli Kistler <Ue...@trivadis.com>.
Hello,

we used different analyzers and regenerated the index each time with the same results...used Luke each time already.
Currently we're using SnowBall and Luke can't find any documents using the supplied query examples below (in zzz-all).

Same happened using StandardAnalyzer (for both, indexing and search).
Using Luke with StandardAnalyzer set, searching for "rz/g/*" results in a query for zzz-all:rz/g/* but with no results.

Any other queries work as expected also using wildcards.

Can anyone think of a possible problem using / (slash) and wildcard characters "?" or "*" ?

Thanks for your help,
Ueli Kistler

-----Ursprüngliche Nachricht-----
Von: Erick Erickson [mailto:erickerickson@gmail.com] 
Gesendet: Donnerstag, 13. August 2009 15:21
An: java-user@lucene.apache.org
Betreff: Re: Wildcard search fails

Several, all of which boil down to "what analyzers are you usingduring
indexing and searching?". Without that information, we can't
say much.

Also, I'd recommend you get a copy of Luke and examine your index
to see whether what's in there is what you expect.

And query.toString and (as Grant says), IndexSearcher.explain() is your
friend

Best
Erick

On Thu, Aug 13, 2009 at 8:19 AM, Ueli Kistler <Ue...@trivadis.com>wrote:

> Hello,
>
>
>
> We're experiencing a problem using Lucene 2.4.1 and Compass 2.1.4 using
> wildcard search.
>
> Attribute values containing slashes can be searched using the full word,
> but not using wildcards. We already tried different analyzers with the
> same result.
>
> Slash isn't mentioned as a stop word only backslash also.
>
>
>
> Example : Searching < RZ/G/17 > and also < RZ/G/22 > succeed, but <
> RZ/G/* > , < RZ/G* > or < RZ/G/ ?? > don't.
>
>
>
> Any ideas why wildcard search doesn't work?
>
>
>
> Thanks,
>
> Ueli Kistler
>
>
>
>

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


Re: Wildcard search fails

Posted by Erick Erickson <er...@gmail.com>.
Several, all of which boil down to "what analyzers are you usingduring
indexing and searching?". Without that information, we can't
say much.

Also, I'd recommend you get a copy of Luke and examine your index
to see whether what's in there is what you expect.

And query.toString and (as Grant says), IndexSearcher.explain() is your
friend

Best
Erick

On Thu, Aug 13, 2009 at 8:19 AM, Ueli Kistler <Ue...@trivadis.com>wrote:

> Hello,
>
>
>
> We're experiencing a problem using Lucene 2.4.1 and Compass 2.1.4 using
> wildcard search.
>
> Attribute values containing slashes can be searched using the full word,
> but not using wildcards. We already tried different analyzers with the
> same result.
>
> Slash isn't mentioned as a stop word only backslash also.
>
>
>
> Example : Searching < RZ/G/17 > and also < RZ/G/22 > succeed, but <
> RZ/G/* > , < RZ/G* > or < RZ/G/ ?? > don't.
>
>
>
> Any ideas why wildcard search doesn't work?
>
>
>
> Thanks,
>
> Ueli Kistler
>
>
>
>