CSV file timestamp compatibility with elasticsearch

Hi,

I have timestamp of a column is like below. For example
2019/04/30 Tuesday 08:00:00

How should I define properties for index mapping

"type" : "date", "format" :"yyyy/MM/dd EEEE HH:mm:ss"

1 Like

Thank you David

Hi David,
I am not able to visualize data in the kibana.
Could you verify this python client code.

 es.indices.put_mapping(
  index=index_name,
  doc_type=doctype,
  ignore=400,
  body={
      doctype: {
          "properties": {
              "@timestamp": {
                  "type": "date",
                  "format": "yyyy/MM/dd EEEE HH:mm:ss"
                  },
              "Load in kW": {
                  "type": "float"
              }
        }
      }
  }

)
for row in reader:
try:
if(index == 0):
headers = row
else:
obj = {}
for i, val in enumerate(row):
if i == 0:
a = datetime.datetime.strptime(val,"%Y/%m/%d %A %H:%M:%S")
obj[headers[i]] = a
else:
obj[headers[i]] = float(val)

          print(obj)
          # put document into elastic search
          es.index(index=index_name, doc_type=doctype, body=obj)

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.