I'm trying to query Solr for entries that either have a certain value in a field OR no value for the field. The negated field value works when used by itself but causes the query to return no results when combined with anything else. Below is a response with debugQuery enabled. The config file I use can be found here.
<?xml version="1.0"?>
<response>
<responseHeader>
<status>0</status>
<QTime>3</QTime>
<lst name="params">
<str name="facet">true</str>
<str name="sort">sort_title asc</str>
<str name="fl">id,nid,url,uid</str>
<str name="debugQuery">true</str>
<str name="facet.mincount">1</str>
<str name="facet.sort">true</str>
<str name="start">0</str>
<str name="bf">recip(rord(created),4.000000,239,239)^200.000000</str>
<arr name="fq">
<str>NOT type:article</str>
<str>NOT type:insect</str>
<str>NOT type:news</str>
<str>NOT type:plant</str>
<str>im_cck_field_affected_plants:(20 OR -[* TO *])</str>
<str>entity:node</str>
</arr>
<str name="version">1.2</str>
<str name="rows">16</str>
</lst>
</responseHeader>
<result name="response" numFound="0" start="0"/>
<lst name="facet_counts">
<lst name="facet_queries"/>
<lst name="facet_fields"/>
<lst name="facet_dates"/>
</lst>
<lst name="debug">
<null name="rawquerystring"/>
<null name="querystring"/>
<str name="parsedquery">+MatchAllDocsQuery(*:*) FunctionQuery((239.0/(4.0*float(top(rord(created)))+239.0))^200.0)</str>
<str name="parsedquery_toString">+*:* (239.0/(4.0*float(top(rord(created)))+239.0))^200.0</str>
<lst name="explain"/>
<str name="QParser">DisMaxQParser</str>
<str name="altquerystring">org.apache.lucene.search.MatchAllDocsQuery:*:*</str>
<arr name="boostfuncs">
<str>recip(rord(created),4.000000,239,239)^200.000000</str>
</arr>
<arr name="filter_queries">
<str>NOT type:article</str>
<str>NOT type:insect</str>
<str>NOT type:news</str>
<str>NOT type:plant</str>
<str>im_cck_field_affected_plants:(20 OR -[* TO *])</str>
<str>entity:node</str>
</arr>
<arr name="parsed_filter_queries">
<str>-type:article</str>
<str>-type:insect</str>
<str>-type:news</str>
<str>-type:plant</str>
<str>im_cck_field_affected_plants:20 -im_cck_field_affected_plants:[* TO *]</str>
<str>entity:node</str>
</arr>
<lst name="timing">
<double name="time">3.0</double>
<lst name="prepare">
<double name="time">3.0</double>
<lst name="org.apache.solr.handler.component.QueryComponent">
<double name="time">2.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.SpellCheckComponent">
<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.SpellCheckComponent">
<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>
Any help would be appreciated.
Finally phrased the question well enough to find an answer through Google.
http://osdir.com/ml/solr-user.lucene.apache.org/2009-03/msg00480.html
OR NOT queries can be written as, using my case as an example:
im_cck_field_affected_plants:20 OR (*:* -im_cck_field_affected_plants:[* TO *])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With