Ah, yes, the FieldType I used was not the one I needed. I completely missed
that. Thank you very much, it's working perfectly now.

thanks,

Stefan Oestreicher

> -----Original Message-----
> From: Erik Hatcher [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, August 12, 2008 11:46 AM
> To: solr-user@lucene.apache.org
> Subject: Re: query parsing
> 
> Solr/Lucene QueryParser returns a TermQuery for "phrases" 
> that end up only as a single term.  This could happen, for 
> example, if it was using Solr's "string" field type (which 
> has effectively no analyzer).
> 
> I'd guess that you'd want to re-analyze TermQuery's?  (though 
> that sound problematic for many cases)  Or possibly use your 
> own SolrQueryParser subclass and override #getFieldQuery.
> 
>       Erik
> 
> On Aug 12, 2008, at 5:26 AM, Stefan Oestreicher wrote:
> 
> > 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