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