Bird
0
0

You have a date field with format yyyy-MM-dd HH:mm:ss||epoch_millis. You want to filter documents where the date is after 2023-07-15 12:00:00. Which query format is correct?

hard🚀 Application Q9 of 15
Elasticsearch - Mappings and Data Types
You have a date field with format yyyy-MM-dd HH:mm:ss||epoch_millis. You want to filter documents where the date is after 2023-07-15 12:00:00. Which query format is correct?
A{"range": {"date_field": {"gt": 1689422400000}}}
B{"range": {"date_field": {"gt": "15-07-2023 12:00:00"}}}
C{"range": {"date_field": {"gt": "2023-07-15 12:00:00"}}}
D{"range": {"date_field": {"gt": "2023/07/15 12:00:00"}}}
Step-by-Step Solution
Solution:
  1. Step 1: Match query date format with mapping formats

    The mapping accepts "yyyy-MM-dd HH:mm:ss" and "epoch_millis" formats.
  2. Step 2: Use string matching the first format

    {"range": {"date_field": {"gt": "2023-07-15 12:00:00"}}} uses the correct string format matching the first format.
  3. Final Answer:

    {"range": {"date_field": {"gt": "2023-07-15 12:00:00"}}} -> Option C
  4. Quick Check:

    Query date format must match mapping format [OK]
Quick Trick: Query dates must match one of the mapping formats exactly [OK]
Common Mistakes:
MISTAKES
  • Using wrong date string format
  • Using epoch millis without quotes
  • Using invalid date separators

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Elasticsearch Quizzes