Query much faster against timestamp in seconds than milliseconds

Numbers are indexed in an inverted index, so each unique value is mapped to the list of documents that contain this value.

To have acceptable performance for range queries, numeric fields also index some prefix terms. For instance long values (which dates are based on) index 4 values by default: one that identifies all bits, one that identifies the first 48 bits, one that identifies the first 32 bits and one that identifies the first 16 bits. These prefix terms help querying fewer terms at search time, which makes search faster: queries typically try to use these terms that match multiple terms and just need to match exact values on the edge of the range. But since we use a precision step of 16 bits, there can still be op to 2^16=65536 values on the edges. However, if your dates are all multiples of 1000, suddenly, there are only ~66 unique values at most on the edges, which helps querying be faster.

Note that as of the next major release, querying will be based on a tree, so the performance characteristics of range queries will become completely different.

3 Likes