Solr
  1. Solr
  2. SOLR-2714

JsonLoader does not handle null field values

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 3.3
    • Fix Version/s: 3.4
    • Component/s: None
    • Labels:
      None

      Description

      The parser in JsonLoader does not handle null fields when adding a document over http+json.

      Given this document:

      [{
        "timestamp":"2011-08-17T14:11:49.201Z",
        "correlationId":"N44YFGSQNC",
        "logType":"event",
        "short":"Invalidating session: 4zy6cvdtmvu1erlay0sn6rhz",
        "long":null
      }]
      

      I'm getting a response code=400 and the error message "should finish doc first" in the logs.

      It seems that JsonLoader is missing case for JSONParser.NULL in the parser even switch.

      1. SOLR-2714.patch
        4 kB
        Yonik Seeley

        Activity

        Hide
        Yonik Seeley added a comment -

        Hmmm, while the JSON loader never advertised the ability to handle null values, there's probably no reason not to do so.
        I guess we should just drop null values.

        Show
        Yonik Seeley added a comment - Hmmm, while the JSON loader never advertised the ability to handle null values, there's probably no reason not to do so. I guess we should just drop null values.
        Hide
        Trygve Laugstøl added a comment -

        Just dropping them sounds good.

        Show
        Trygve Laugstøl added a comment - Just dropping them sounds good.
        Hide
        Neil Hooey added a comment -

        If you had some sort of IntOrNull value, that had a default value of 0, and you indexed it as null with /update/json, dropping the null would make the value 0 instead.

        Is there any data type in Solr that can be a value, or null? If not, then dropping the nulls is fine.

        Show
        Neil Hooey added a comment - If you had some sort of IntOrNull value, that had a default value of 0, and you indexed it as null with /update/json, dropping the null would make the value 0 instead. Is there any data type in Solr that can be a value, or null? If not, then dropping the nulls is fine.
        Hide
        Yonik Seeley added a comment -

        Here's a patch that drops null values.

        Show
        Yonik Seeley added a comment - Here's a patch that drops null values.
        Hide
        Robert Muir added a comment -

        bulk close for 3.4

        Show
        Robert Muir added a comment - bulk close for 3.4

          People

          • Assignee:
            Unassigned
            Reporter:
            Trygve Laugstøl
          • Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development