Lesson 3 — Structure and numbers
/ Tutorial, / Sort, / RangeLesson 3 — Structure and numbers #
Ranges, sorts, and cursor pagination over the sales collection (120
documents: type, price, qty, amount, merchant, status, date).
The use case #
Most queries are not about words — they are filters and ordering over the structured half of the document: prices, quantities, timestamps. And real interfaces page through result sets, sometimes deeply. The questions this lesson answers:
- “Sales priced $45 to $60” / “everything from 2024” —
rangeover a typed field. - “Top 5 by amount” — the canonical
sortclause. - “Page 3000 of a big result set, without re-ranking the world” —
cursor pagination (
search_after), wherefrom+sizebreaks down. - “Why did my filter miss the row with
45?” — the field-type system:45the number and"45"the keyword are different values.
The types behind the data #
Numbers are indexed as their real types (float for price, integers for
qty), dates as epoch millis. That is what makes the queries below precise
— see the
field types reference for the
full catalog.