I am running in to the same issue. I have tried to replace my
WhitespaceTokenizerFactory with a PatternTokenizerFactory with pattern
(\s+|-) but I still seem to get a phrase query. Why is that?




Ahmet Arslan wrote:
> 
> 
>> I am using Solr 1.3.
>> I have an index with a field called "name". It is of type
>> "text"
>> (unmodified, stock text field from solr).
>> 
>> My query
>> field:foo-bar
>> is parsed as a phrase query
>> field:"foo bar"
>> 
>> I was rather expecting it to be parsed as
>> field:(foo bar)
>> or
>> field:foo field:bar
>> 
>> Is there an expectation mismatch? Can I make it work as I
>> expect it to?
> 
> If the query analyzer produces two or more tokens from a single token,
> QueryParser constructs PhraseQuery. Therefore it is expected. 
> 
> Without writing custom code it seems impossible to alter this behavior.
> 
> Modifying QueryParser to change this behavior will be troublesome. 
> I think easiest way is to replace '-' with whitespace before analysis
> phase. Probably in client side. Or in an custom RequestHandler.
> 
> May be you can set qp.setPhraseSlop(Integer.MAX_VALUE); so that 
> field:foo-bar and field:(foo AND bar) will be virtually equal.
> 
> hope this helps.
> 
> 
>       
> 
> 

-- 
View this message in context: 
http://old.nabble.com/Understanding-the-query-parser-tp27071483p27107523.html
Sent from the Solr - User mailing list archive at Nabble.com.

Reply via email to