lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robert Muir (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (SOLR-5231) When a boolean field is missing from a doc it is sometimes treated as "true" by the "if" function (based on other docs in segment?)
Date Wed, 11 Sep 2013 00:15:52 GMT

    [ https://issues.apache.org/jira/browse/SOLR-5231?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13763752#comment-13763752
] 

Robert Muir commented on SOLR-5231:
-----------------------------------

The bug is BoolField.BoolDocValues.

look at its implementation of boolVal.

If there are no values in the segment at all "trueOrd" is -1 (which is bogus).

{noformat}
Index: solr/core/src/java/org/apache/solr/schema/BoolField.java
===================================================================
--- solr/core/src/java/org/apache/solr/schema/BoolField.java	(revision 1521538)
+++ solr/core/src/java/org/apache/solr/schema/BoolField.java	(working copy)
@@ -182,7 +182,8 @@
       }
     }
 
-    final int trueOrd = tord;
+    // if there were no values in the segment, dont let trueOrd be -1 (missing)
+    final int trueOrd = tord >= 0 ? tord : -2;
 
     return new BoolDocValues(this) {
       @Override
{noformat}
                
> When a boolean field is missing from a doc it is sometimes treated as "true" by the "if"
function (based on other docs in segment?)
> -----------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: SOLR-5231
>                 URL: https://issues.apache.org/jira/browse/SOLR-5231
>             Project: Solr
>          Issue Type: Bug
>    Affects Versions: 4.4
>            Reporter: Hoss Man
>
> This issue is hard to explain with out a long example.
> crux of the problem is that the behavior of the if function, wrapped arround a boolean
field (ie: "{{if(fieldName,x,y)}}" ) is not consistent for documents that do not have any
value for that functio -- the behavior seems to  depend on whether or not other documents
in the same segment have a value for that field.
> for brevity, details will follow in a comment - but i've been able to reproduce on trunk,
4.3, and 4.3 (didn't look back farther then that)
> the work around is to explicitly use the {{exists()}} function in the if condition (ie:
"{{if(exists(fieldName),x,y)}}" )
> (Thanks to Elodie Sannier for reporting the initial symptoms of this on the mailing list)

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


Mime
View raw message