Solr
  1. Solr
  2. SOLR-4297

Atomic update including set null=true throws uniqueKey error depending on order

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 4.0, 4.1
    • Fix Version/s: 4.3, 6.0
    • Component/s: clients - java, update
    • Labels:
      None

      Description

      There seems to be a field order issue going on when setting a field to null with a partial update. I am running the nightly Solr 4.1.0.2013.01.11.08.23.02 build. Ran into this issue using the nightly build version of Solrj, including the null field fix from Solr-4133.

      Null first, unique field second (this is what is being generated by Solrj)

      curl 'http://localhost/solr/update?commit=true' -H 'Content-type:text/xml' -d '<add><doc boost="1.0">
      <field name="timestamp" update="set" null="true"/><field name="id">test</field>
      </doc></add>'
      
      <?xml version="1.0" encoding="UTF-8"?>
      <response>
      <lst name="responseHeader"><int name="status">400</int><int name="QTime">0</int></lst><lst name="error"><str name="msg">Document is missing mandatory uniqueKey field: id</str><int name="code">400</int></lst>
      </response>
      

      id first, then null field

      curl 'http://localhost/solr/update?commit=true' -H 'Content-type:text/xml' -d '<add><doc boost="1.0">
      <field name="id">test</field>
      <field name="timestamp" update="set" null="true"/>
      </doc></add>'
      
      <response>
      <lst name="responseHeader"><int name="status">0</int><int name="QTime">30</int></lst>
      </response>
      

      Real value first, then id

      curl 'http://localhost/solr/update?commit=true' -H 'Content-type:text/xml' -d '<add><doc boost="1.0">
      <field name="timestamp" update="set">1970-01-01T00:00:00Z</field>
      <field name="id">test</field>
      </doc></add>'
      
      <?xml version="1.0" encoding="UTF-8"?>
      <response>
      <lst name="responseHeader"><int name="status">0</int><int name="QTime">28</int></lst>
      </response>
      

      Unfortunately it is doing this field ordering every atomic update request via Solrj I do now.

      1. SOLR-4297.patch
        2 kB
        Shalin Shekhar Mangar

        Activity

        Hide
        Rob added a comment -

        Based on its behavior it seems like having set=null results in the server flagging all subsequent elements from that update to be removed. (Hence the error message above noting that the mandatory Id is missing.

        As a further example:

        If I have the null=true cat field at the end of the doc

        <add><doc><field name="id">Item1</field><field name="manu" update="set">Hello</field><field name="cat" update="set" null="true" /></doc>
        

        The resulting indexed document looks something like

        <doc><str name="id">GB18030TEST</str><str name="manu">Hello</str></doc>

        however if we place the null=true element before the manu element like thus

        <add><doc><field name="id">Item1</field><field name="cat" update="set" null="true" /><field name="manu" update="set">World</field></doc>

        then manu item is also cleared although all other other fields not provided in the update do hang around.
        The work around at the moment as noted is to ensure that all null=true fields are placed at the end of the doc.

        Show
        Rob added a comment - Based on its behavior it seems like having set=null results in the server flagging all subsequent elements from that update to be removed. (Hence the error message above noting that the mandatory Id is missing. As a further example: If I have the null=true cat field at the end of the doc <add> <doc> <field name= "id" > Item1 </field> <field name= "manu" update= "set" > Hello </field> <field name= "cat" update= "set" null= "true" /> </doc> The resulting indexed document looks something like <doc> <str name= "id" > GB18030TEST </str> <str name= "manu" > Hello </str> </doc> however if we place the null=true element before the manu element like thus <add> <doc> <field name= "id" > Item1 </field> <field name= "cat" update= "set" null= "true" /> <field name= "manu" update= "set" > World </field> </doc> then manu item is also cleared although all other other fields not provided in the update do hang around. The work around at the moment as noted is to ensure that all null=true fields are placed at the end of the doc.
        Hide
        Shalin Shekhar Mangar added a comment -

        Test and fix.

        Show
        Shalin Shekhar Mangar added a comment - Test and fix.
        Hide
        Commit Tag Bot added a comment -

        [trunk commit] Shalin Shekhar Mangar
        http://svn.apache.org/viewvc?view=revision&revision=1456322

        SOLR-4297: Atomic update request containing null=true sets all subsequent fields to null

        Show
        Commit Tag Bot added a comment - [trunk commit] Shalin Shekhar Mangar http://svn.apache.org/viewvc?view=revision&revision=1456322 SOLR-4297 : Atomic update request containing null=true sets all subsequent fields to null
        Hide
        Shalin Shekhar Mangar added a comment -

        Fixed in branch_4x and trunk.

        Show
        Shalin Shekhar Mangar added a comment - Fixed in branch_4x and trunk.
        Hide
        Commit Tag Bot added a comment -

        [branch_4x commit] Shalin Shekhar Mangar
        http://svn.apache.org/viewvc?view=revision&revision=1456323

        SOLR-4297: Atomic update request containing null=true sets all subsequent fields to null

        Show
        Commit Tag Bot added a comment - [branch_4x commit] Shalin Shekhar Mangar http://svn.apache.org/viewvc?view=revision&revision=1456323 SOLR-4297 : Atomic update request containing null=true sets all subsequent fields to null
        Hide
        Commit Tag Bot added a comment -

        [trunk commit] Mark Robert Miller
        http://svn.apache.org/viewvc?view=revision&revision=1458392

        SOLR-4297: Move CHANGES entry.

        Show
        Commit Tag Bot added a comment - [trunk commit] Mark Robert Miller http://svn.apache.org/viewvc?view=revision&revision=1458392 SOLR-4297 : Move CHANGES entry.
        Hide
        Commit Tag Bot added a comment -

        [branch_4x commit] Mark Robert Miller
        http://svn.apache.org/viewvc?view=revision&revision=1458396

        SOLR-4297: Move CHANGES entry.

        Show
        Commit Tag Bot added a comment - [branch_4x commit] Mark Robert Miller http://svn.apache.org/viewvc?view=revision&revision=1458396 SOLR-4297 : Move CHANGES entry.
        Hide
        Uwe Schindler added a comment -

        Closed after release.

        Show
        Uwe Schindler added a comment - Closed after release.

          People

          • Assignee:
            Shalin Shekhar Mangar
            Reporter:
            Ben Pennell
          • Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development