Hi,

I need to modify the query to search through all fields if no explicit field
has been specified. I know there's the dismax handler but I'd like to use
the standard query syntax.
I implemented that with my own QParserPlugin and QParser and for simple term
queries it works great. I'm using the SolrQueryParser which I get from the
schema to parse the query with an impossible field name as the default field
and then I rewrite the query accordingly.
Unfortunately this doesn't work with phrase queries, the SolrQueryParser
always returns a TermQuery instead of a phrase query.

What am I missing? Is this even a viable approach?

This is a code snippet from a test case (extending AbstractSolrTestCase)
which I used to verify that it's not returning a PhraseQuery:

-----8<-----
SolrQueryParser parser = h.getCore().getSchema().getSolrQueryParser(null);
Query q = parser.parse("baz \"foo bar\"");
assertTrue( q instanceof BooleanQuery );
BooleanQuery bq = (BooleanQuery)q;
BooleanClause[] cl = bq.getClauses();
assertEquals(2, cl.length);
//this assertion fails
assertTrue(cl[1].getQuery() instanceof PhraseQuery);
-----8<-----

I'm using solr 1.3, r685085.

TIA,
 
Stefan Oestreicher

Reply via email to