elasticsearch-dsl-py icon indicating copy to clipboard operation
elasticsearch-dsl-py copied to clipboard

Cannot save when the Date format is yyyy-MM-dd

Open horennel opened this issue 3 years ago • 1 comments

model:

class EsModel(Document):
    releaseAt = Date(format='yyyy-MM-dd')
    releaseAtTime = Long()

es mapping

"mappings" : {
      "properties" : {
        "releaseAt" : {
          "type" : "date",
          "format" : "yyyy-MM-dd"
        },
        "releaseAtTime" : {
          "type" : "long"
        }
      }
    }

my input:

releaseAt(str):'2022-01-20'
releaseAtTime(int):1642664160000

error: elasticsearch.exceptions.RequestError: RequestError(400, 'mapper_parsing_exception', "failed to parse field [releaseAt] of type [date] in document with id 'eleddn4BkzUpslRo1a-e'. Preview of field's value: '2022-01-20T00:00:00'")

horennel avatar Jan 20 '22 08:01 horennel

Now the only way to save successfully is to change the Date(format='yyyy-MM-dd') in the code to keyword () after EsModel.init()

horennel avatar Jan 20 '22 08:01 horennel