maaz
maaz

Reputation: 4493

Performance impact of big field name and date type in Elasticsearch

I am investigating performance impact of long fields name in document
example created_timestamp_field1 vs ctf1

Q1) Which is preferred or best practice for field value and is there any performance / storage benefit?

Also is there any impact of storing date as long or in some format
example 0000 vs 1 Jan 1970 00:00:00.
date is eventually converted in long so not sure there is any impact of it in performance or storage

Q2) Is there any impact of using any of the above date value?

Upvotes: 0

Views: 557

Answers (1)

ramseykhalaf
ramseykhalaf

Reputation: 3400

  1. I don't know the answer to this. JSON docs are hashtables though, so I wouldn't have thought this would matter much in terms of performance and storage. HOWEVER you will have more network traffic.

  2. Use the date type: date in your mapping and you can define any format you want to send it in. They will all be converted to elasticsearch's date format anyway. If you use the date format you can do date math (e.g. range:{ posted_date: now-1w } to get docs in the last week). Have a read of the es docs on mapping, scroll down to the date section. You can find out more about date formats too!

Example mapping

"posted_date": {
  "type": "date",
  "format": "yyyy/MM/dd HH:mm:ss||yyyy/MM/dd"
}

Good luck!

Upvotes: 1

Related Questions