Difference range query between numeric type and range type

i Think this article says that range type is better way for range query.

example 1)
doc mapping : start_date(date) and end_date(date)
query description : start_date < criteria && criteria < end_date via range query

example 2_
doc mapping : date (date_range)
query description : start_date < criteria && criteria < end_date via term query

is there any difference of performance between example1 and example2?

thanks

It's a different use-case, so comparing performance does not make much sense in some ways. If the second example solves your use-case I'd always go with that simplified solution. The range example is useful for hotel room reservations, employee holiday planning ("who is gone from 1st till the 31st of August") etc.

Hope this helps!

1 Like