[Documentation] Example of the `@timestamp` datetime format when creating documents: `DateTimeFormatter.ISO_DATE_TIME.format(OffsetDateTime.now())`
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 35/100
- Issue type
- Documentation
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- elasticsearch, java
- Domain
- documentation, search
Research direction
Start by locating the Elasticsearch Java client documentation for creating documents and the examples that show date fields. Add a @timestamp creation example using a timezone-aware value, and verify that the documentation clearly distinguishes it from LocalDateTime.
Written by the indexing model from the issue text.
Description
Description
It's quite easy to shoot yourself in the foot with the @timestamp date format and Kibana returns no data without assistance to identify the problem.
Can you please provide an example to create a document including a @timestamp field?
Note that I eventually fixed my problem using DateTimeFormatter.ISO_DATE_TIME.format(OffsetDateTime.now()).
Example of the mistake I did:
- Create an index specifying the
datetype for the@timestampfield - Used the Elasticsearch Java client to insert a document setting
@timestamptoLocalDateTime.now().toString()(- ⚠️
LocalDateTimeis wrong,@timestamprequires a timezone, useDateTimeFormatter.ISO_DATE_TIME.format(OffsetDateTime.now())
- ⚠️
- The document was successfully inserted
- Verify the document was successfully inserted retrieving it using the Elasticsearch APIs
- Try and fail to visualize in Kibana Discover.
- We discovered that the cause was the invalid format of
@timestampthat was lacking of a timezone, it didn't work with the range query of Kibana Discover:
{
"range":{
"@timestamp":{
"format":"strict_date_optional_time",
"gte":"1923-03-18T13:16:11.509Z",
"lte":"2022-03-18T12:16:11.509Z"
}
}
}
FYI @rayafratkina helped me to figure out this problem
- Dominant language
- Java
- Stars
- 524
- Forks
- 300
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 16
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from elastic/elasticsearch-java
-
Difficulty 3/5 1-2 days Newbie friendliness 72/100
elastic/elasticsearch-java#1339 · 3 comments · 1 assignee ·
-
Difficulty 5/5 Over a week Newbie friendliness 45/100
elastic/elasticsearch-java#1212 · 8 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
elastic/elasticsearch-java#1165 · 5 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
elastic/elasticsearch-java#1083 · 2 comments ·
-
Area: Generator Category: Enhancement
Difficulty 3/5 1-2 days Newbie friendliness 48/100
elastic/elasticsearch-java#1034 · 2 comments ·
All issues in elastic/elasticsearch-java
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
infinispan/infinispan#18150 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
opensearch-project/k-NN#3597 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100