lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hoss Man (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 Tue, 10 Sep 2013 23:47:53 GMT

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

Hoss Man commented on SOLR-5231:
--------------------------------

Start with a completely empty index, using the example configs -- the only thing that probably
really matters is that you have a boolean field named "inStock" defined.

Add a single document w/o the inStock field and commit...

{noformat}
$ java -Ddata=args -Durl=http://localhost:8983/solr/collection1/update -jar post.jar '<add><doc><field
name="id">NOVAL</field></doc></add>'
SimplePostTool version 1.5
POSTing args to http://localhost:8983/solr/collection1/update..
COMMITting Solr index changes to http://localhost:8983/solr/collection1/update..
Time spent: 0:00:00.451
$ curl 'http://localhost:8983/solr/collection1/select?indent=true&q=*:*&fl=id,inStock,exists(inStock),if(inStock,42,-99),if(exists(inStock),42,-99)'
<?xml version="1.0" encoding="UTF-8"?>
<response>

<lst name="responseHeader">
  <int name="status">0</int>
  <int name="QTime">20</int>
  <lst name="params">
    <str name="fl">id,inStock,exists(inStock),if(inStock,42,-99),if(exists(inStock),42,-99)</str>
    <str name="indent">true</str>
    <str name="q">*:*</str>
  </lst>
</lst>
<result name="response" numFound="1" start="0">
  <doc>
    <str name="id">NOVAL</str>
    <bool name="exists(inStock)">false</bool>
    <long name="if(inStock,42,-99)">42</long>
    <long name="if(exists(inStock),42,-99)">-99</long></doc>
</result>
</response>
{noformat}

note that the exists() function behalves correctly, but the if() function does not (unless
it is used to wrap exists()

next, add some more docs that do in fact have values...

{noformat}
$ java -Ddata=args -Durl=http://localhost:8983/solr/collection1/update -jar post.jar '<add><doc><field
name="id">FALSE</field><field name="inStock">false</field></doc></add>'SimplePostTool
version 1.5
POSTing args to http://localhost:8983/solr/collection1/update..
COMMITting Solr index changes to http://localhost:8983/solr/collection1/update..
Time spent: 0:00:00.356
$ curl 'http://localhost:8983/solr/collection1/select?indent=true&q=*:*&fl=id,inStock,exists(inStock),if(inStock,42,-99),if(exists(inStock),42,-99)'
<?xml version="1.0" encoding="UTF-8"?>
<response>

<lst name="responseHeader">
  <int name="status">0</int>
  <int name="QTime">1</int>
  <lst name="params">
    <str name="fl">id,inStock,exists(inStock),if(inStock,42,-99),if(exists(inStock),42,-99)</str>
    <str name="indent">true</str>
    <str name="q">*:*</str>
  </lst>
</lst>
<result name="response" numFound="2" start="0">
  <doc>
    <str name="id">NOVAL</str>
    <bool name="exists(inStock)">false</bool>
    <long name="if(inStock,42,-99)">42</long>
    <long name="if(exists(inStock),42,-99)">-99</long></doc>
  <doc>
    <str name="id">FALSE</str>
    <bool name="inStock">false</bool>
    <bool name="exists(inStock)">true</bool>
    <long name="if(inStock,42,-99)">-99</long>
    <long name="if(exists(inStock),42,-99)">42</long></doc>
</result>
</response>
$ java -Ddata=args -Durl=http://localhost:8983/solr/collection1/update -jar post.jar '<add><doc><field
name="id">TRUE</field><field name="inStock">true</field></doc></add>'
SimplePostTool version 1.5
POSTing args to http://localhost:8983/solr/collection1/update..
COMMITting Solr index changes to http://localhost:8983/solr/collection1/update..
Time spent: 0:00:00.356
$ curl 'http://localhost:8983/solr/collection1/select?indent=true&q=*:*&fl=id,inStock,exists(inStock),if(inStock,42,-99),if(exists(inStock),42,-99)'
<?xml version="1.0" encoding="UTF-8"?>
<response>

<lst name="responseHeader">
  <int name="status">0</int>
  <int name="QTime">2</int>
  <lst name="params">
    <str name="fl">id,inStock,exists(inStock),if(inStock,42,-99),if(exists(inStock),42,-99)</str>
    <str name="indent">true</str>
    <str name="q">*:*</str>
  </lst>
</lst>
<result name="response" numFound="3" start="0">
  <doc>
    <str name="id">NOVAL</str>
    <bool name="exists(inStock)">false</bool>
    <long name="if(inStock,42,-99)">42</long>
    <long name="if(exists(inStock),42,-99)">-99</long></doc>
  <doc>
    <str name="id">FALSE</str>
    <bool name="inStock">false</bool>
    <bool name="exists(inStock)">true</bool>
    <long name="if(inStock,42,-99)">-99</long>
    <long name="if(exists(inStock),42,-99)">42</long></doc>
  <doc>
    <str name="id">TRUE</str>
    <bool name="inStock">true</bool>
    <bool name="exists(inStock)">true</bool>
    <long name="if(inStock,42,-99)">42</long>
    <long name="if(exists(inStock),42,-99)">42</long></doc>
</result>
</response>
{noformat}

note that each time we add a doc, the functions behalf as expected for these new docs, but
still the {{if(inStock,...)}} on our NOVAL doc is not behaving.

next, let's optimize to put all the docs in a single segment...

{noformat}
$ java -Ddata=args -Durl=http://localhost:8983/solr/collection1/update -jar post.jar '<optimize/>'SimplePostTool
version 1.5
POSTing args to http://localhost:8983/solr/collection1/update..
COMMITting Solr index changes to http://localhost:8983/solr/collection1/update..
Time spent: 0:00:00.382
$ curl 'http://localhost:8983/solr/collection1/select?indent=true&q=*:*&fl=id,inStock,exists(inStock),if(inStock,42,-99),if(exists(inStock),42,-99)'
<?xml version="1.0" encoding="UTF-8"?>
<response>

<lst name="responseHeader">
  <int name="status">0</int>
  <int name="QTime">2</int>
  <lst name="params">
    <str name="fl">id,inStock,exists(inStock),if(inStock,42,-99),if(exists(inStock),42,-99)</str>
    <str name="indent">true</str>
    <str name="q">*:*</str>
  </lst>
</lst>
<result name="response" numFound="3" start="0">
  <doc>
    <str name="id">FALSE</str>
    <bool name="inStock">false</bool>
    <bool name="exists(inStock)">true</bool>
    <long name="if(inStock,42,-99)">-99</long>
    <long name="if(exists(inStock),42,-99)">42</long></doc>
  <doc>
    <str name="id">TRUE</str>
    <bool name="inStock">true</bool>
    <bool name="exists(inStock)">true</bool>
    <long name="if(inStock,42,-99)">42</long>
    <long name="if(exists(inStock),42,-99)">42</long></doc>
  <doc>
    <str name="id">NOVAL</str>
    <bool name="exists(inStock)">false</bool>
    <long name="if(inStock,42,-99)">-99</long>
    <long name="if(exists(inStock),42,-99)">-99</long></doc>
</result>
</response>
{noformat}

Now suddenly our NOVAL doc behaves as expected, and if function returns the false clause.
                
> 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