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 Le...@emc.com on 2006/05/10 19:47:43 UTC

wildcards in phrase searches

Is it possible to have wildcards in a phrase search? For example, if my
object is indexed with a phrase "benchmark properties", is there a way to
specify a phrase search that uses wildcards, such as "benchmar* properties"
or "benchmark pro*"? I have tried using WildcardQuery, but it doesnt seem to
work with phrases, only single terms. Using the QueryParser doesnt seem to
work either, and ive tried it with the StandardAnalyzer and KeywordAnalyzer.
Perhaps there is something simple Im missing here. Has anyone gotten this to
work?
 
Thanks in advance,
-G

Re: wildcards in phrase searches

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
On May 10, 2006, at 1:47 PM, Lee_Gary@emc.com wrote:

> Is it possible to have wildcards in a phrase search? For example,  
> if my
> object is indexed with a phrase "benchmark properties", is there a  
> way to
> specify a phrase search that uses wildcards, such as "benchmar*  
> properties"
> or "benchmark pro*"? I have tried using WildcardQuery, but it  
> doesnt seem to
> work with phrases, only single terms. Using the QueryParser doesnt  
> seem to
> work either, and ive tried it with the StandardAnalyzer and  
> KeywordAnalyzer.
> Perhaps there is something simple Im missing here. Has anyone  
> gotten this to
> work?

It's a fair bit trickier than using any of the stock core classes  
like that.  But it can be done, using SpanNearQuery nested with  
SpanRegexQuery's for the wildcarded parts in the contrib code (note,  
this uses regex syntax, not WildcardQuery syntax), along with  
SpanTermQuery's for the non-wildcarded parts.

	Erik


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