Uploaded image for project: 'Hibernate Search'
  1. HSEARCH-3255

Handle .onMissingValue().use() properly for date fields in Elasticsearch

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects versions: None
    • Fix versions: 6.0.0.Alpha7
    • Components: backend-elasticsearch
    • Labels:
      None

      Description

      It might be fixed in ES 6, but at least in Elasticsearch 5, calling .onMissingValue().use( ... ) on a LocalDate field leads to a failure to parse the date on the Elasticsearch side.

      Verified in ES 5.4 and 5.6.5.
      We should check later versions and report it if necessary, or adapt our code if it's not a bug.

      Note that sending a integer value works correctly, see for example the codec for Instant. Maybe we should have two "encode" methods in the codec, one for the sort and one for everything else?

      Logs:

      15:26:01,612 (Hibernate Search: Elasticsearch transport thread-2) TRACE request:188 - HSEARCH-ES000093: Executed Elasticsearch HTTP POST request to path '/indexname/_search' with query parameters {} in 7ms. Response had status 400 'Bad Request'. Request body: <
      {
        "query": {
          "match_all": {}
        },
        "sort": [
          {
            "localDate": {
              "order": "asc",
              "missing": "2018-01-01"
            }
          }
        ]
      }
      >. Response body: <
      {
        "error": {
          "root_cause": [
            {
              "type": "number_format_exception",
              "reason": "For input string: \"2018-01-01\""
            }
          ],
          "type": "search_phase_execution_exception",
          "reason": "all shards failed",
          "phase": "query",
          "grouped": true,
          "failed_shards": [
            {
              "shard": 0,
              "index": "indexname",
              "node": "kEfK1PAbRweMpBcBp1Xm8Q",
              "reason": {
                "type": "number_format_exception",
                "reason": "For input string: \"2018-01-01\""
              }
            }
          ]
        },
        "status": 400
      }
      >
      

        Attachments

          Issue links

            Activity

              People

              • Assignee:
                fercoli Fabio Massimo Ercoli
                Reporter:
                yrodiere Yoann Rodière
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: