We're updating the issue view to help you get more done. 

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

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:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 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 } >

Environment

None

Status

Assignee

Fabio Massimo Ercoli

Reporter

Yoann Rodière

Labels

None

Suitable for new contributors

None

Feedback Requested

None

Components

Fix versions

Priority

Major