You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Chris Hostetter <ho...@fucit.org> on 2008/01/08 09:43:00 UTC

Re: PhraseQuery and WildcardQuery

: I've got this error when trying to search query like q=+myFiled:"some
: value"*
: 
: org.apache.solr.core.SolrException: Query parsing error: Cannot parse
: '+myFiled:"some value"*': '*' or '?' not allowed as first character in
: WildcardQuery
	...

...this is where the subtleties of the Lucene QueryParser come into place 
... where concepts like "word", "term", and "phrase" all collide.  No, you 
cannot use wildcards with a quoted phrase query.  

: p.s. unexpected - this query works just fine: q=+myFiled:some\ value*
:       so I can just escape all control symbols and space - and I'll get what

be carefully ... that's probably not doing what you think it's doing.  
it's searching for a documents which contain a single term that starts 
with the characters "some value" ... if you indexed with a tokenizer that 
splits on whitespace, or does any lowercasing, or does anything 
interesting at all in the analyzer, this won't match those docs.  

This is generally true for prefix queries, but people might be confused 
and think what they are getting with that syntax is a search for something 
matching "some" followed by a prefix query for "value*" ... if you indexed 
a doc containg "some the values" with a StopFilter to get rid of "the", 
that doc won't match your query.

I say this jsut to clarify for people who see this thread: that syntax 
trick might work fine for you if you know you have a very special case, but 
it probably won't do what many people expect it to.

:       But there are no info about space escaping at
: http://lucene.apache.org/java/docs/queryparsersyntax.html#Escaping%20Special%20Characters

Hmmm...  i'll file bug on that.




-Hoss


Re: PhraseQuery and WildcardQuery

Posted by Traut <tr...@gmail.com>.
Thank you for the clarification.

On Jan 8, 2008 10:43 AM, Chris Hostetter <ho...@fucit.org> wrote:

> : I've got this error when trying to search query like q=+myFiled:"some
> : value"*
> :
> : org.apache.solr.core.SolrException: Query parsing error: Cannot parse
> : '+myFiled:"some value"*': '*' or '?' not allowed as first character in
> : WildcardQuery
>        ...
>
> ...this is where the subtleties of the Lucene QueryParser come into place
> ... where concepts like "word", "term", and "phrase" all collide.  No, you
> cannot use wildcards with a quoted phrase query.
>
> : p.s. unexpected - this query works just fine: q=+myFiled:some\ value*
> :       so I can just escape all control symbols and space - and I'll get
> what
>
> be carefully ... that's probably not doing what you think it's doing.
> it's searching for a documents which contain a single term that starts
> with the characters "some value" ... if you indexed with a tokenizer that
> splits on whitespace, or does any lowercasing, or does anything
> interesting at all in the analyzer, this won't match those docs.
>
> This is generally true for prefix queries, but people might be confused
> and think what they are getting with that syntax is a search for something
> matching "some" followed by a prefix query for "value*" ... if you indexed
> a doc containg "some the values" with a StopFilter to get rid of "the",
> that doc won't match your query.
>
> I say this jsut to clarify for people who see this thread: that syntax
> trick might work fine for you if you know you have a very special case,
> but
> it probably won't do what many people expect it to.
>
> :       But there are no info about space escaping at
> :
> http://lucene.apache.org/java/docs/queryparsersyntax.html#Escaping%20Special%20Characters
>
> Hmmm...  i'll file bug on that.
>
>
>
>
> -Hoss
>
>


-- 
Best regards,
Traut