Because Lucene query syntax is not a strict Boolean logic system. There's a good explanation here: http://www.lucidimagination.com/blog/2011/12/28/why-not-and-or-and-not/
Adding &debugQuery=on to your search is your friend <G>.. You'll see that your return (at least on 3.5 with going at /solr/select) returns this as the parsed query: <str name="parsedquery">-name:foobar</str> Solr really doesn't have the semantics for empty strings (or NULL for that matter) so it just gets dropped out. Best Erick On Sun, Mar 11, 2012 at 11:36 PM, Lan <dung....@gmail.com> wrote: > I am curious why solr results are inconsistent for the query below for an > empty string search on a TextField. > > q=name:"" returns 0 results > q=name:"" AND NOT name:"FOOBAR" return all results in the solr index. Should > it should not return 0 results too? > > Here is the debugQuery. > > <response> > <lst name="responseHeader"> > <int name="status">0</int> > <int name="QTime">1</int> > <lst name="params"> > <str name="debugQuery">on</str> > <str name="indent">on</str> > <str name="start">0</str> > <str name="q">name:"" AND NOT name:"BLAH232282"</str> > <str name="rows">0</str> > <str name="version">2.2</str> > </lst> > </lst> > <result name="response" numFound="3790790" start="0"/> > <lst name="debug"> > <str name="rawquerystring">name:"" AND NOT name:"BLAH232282"</str> > <str name="querystring">name:"" AND NOT name:"BLAH232282"</str> > <str name="parsedquery">-PhraseQuery(name:"blah 232282")</str> > <str name="parsedquery_toString">-name:"blah 232282"</str> > <lst name="explain"/> > <str name="QParser">LuceneQParser</str> > <lst name="timing"> > <double name="time">1.0</double> > <lst name="prepare"> > <double name="time">1.0</double> > <lst name="org.apache.solr.handler.component.QueryComponent"> > <double name="time">1.0</double> > </lst> > <lst name="org.apache.solr.handler.component.FacetComponent"> > <double name="time">0.0</double> > </lst> > <lst name="org.apache.solr.handler.component.MoreLikeThisComponent"> > <double name="time">0.0</double> > </lst> > <lst name="org.apache.solr.handler.component.HighlightComponent"> > <double name="time">0.0</double> > </lst> > <lst name="org.apache.solr.handler.component.StatsComponent"> > <double name="time">0.0</double> > </lst> > <lst name="org.apache.solr.handler.component.DebugComponent"> > <double name="time">0.0</double> > </lst> > </lst> > <lst name="process"> > <double name="time">0.0</double> > <lst name="org.apache.solr.handler.component.QueryComponent"> > <double name="time">0.0</double> > </lst> > <lst name="org.apache.solr.handler.component.FacetComponent"> > <double name="time">0.0</double> > </lst> > <lst name="org.apache.solr.handler.component.MoreLikeThisComponent"> > <double name="time">0.0</double> > </lst> > <lst name="org.apache.solr.handler.component.HighlightComponent"> > <double name="time">0.0</double> > </lst> > <lst name="org.apache.solr.handler.component.StatsComponent"> > <double name="time">0.0</double> > </lst> > <lst name="org.apache.solr.handler.component.DebugComponent"> > <double name="time">0.0</double> > </lst> > </lst> > </lst> > </lst> > </response> > > > -- > View this message in context: > http://lucene.472066.n3.nabble.com/Strange-behavior-with-search-on-empty-string-and-NOT-tp3818023p3818023.html > Sent from the Solr - User mailing list archive at Nabble.com.