Repository navigation
feat(search)!: declare date facet bins in ISO 8601, with max covering its whole period - #991
Merged
Merged
Conversation
- Split NumericField into NumberField and DateField; a date's
facetRanges are DateFacetRange, with ISO 8601 bounds
- Add storedFacetRanges, which gives an adapter the bins in Unix
seconds; the Typesense adapter compiles and echoes through it
- Reject a date bin bound the codec cannot read
- Serve a binned date facet's buckets as DateRangeBucket, its bounds
ISO8601Date at the precision they were declared in
BREAKING CHANGE: a date field's facetRanges take ISO 8601 strings
instead of Unix seconds ({ min: '1900', max: '2000' }), and its
binned buckets are DateRangeBucket instead of RangeBucket.
NumericField is now a union of NumberField and DateField.
- Add lastSecondOf, the last stored second of a date's period - Compile a date range filter's max to the end of its period, so max: '1999' runs through 1999 - Make a date bin inclusive at both ends, like the filter; its stored max is the first second after its period, so bins and the filter that selects them count the same documents BREAKING CHANGE: a date range filter's max, and a date bin's max, now include the whole period they name. max: '2000' used to stop at the first second of 2000 and now runs through its end; write max: '1999' for a range that ends with 1999.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A date field’s
facetRangeswere the one place a caller still wrote a date in Unix seconds, and the GraphQL surface served those bins asRangeBucketwithFloatbounds. Both are now ISO 8601, and a datemax– in a bin or a filter – now includes the whole period it names.Why
maxcovers the whole periodA date bound used to be the first second of the period it names, and bins were half-open while the
DateRangefilter is inclusive. A year-only record is stored at that first second, so a bin[1900, 2000)fed back into the filter as{ min: '1900', max: '2000' }picked up every record dated just2000: the result count no longer matched the bucket. And anyone writing “1900 to 1999” asmax: '1999'silently lost 1999.Now
max: '1999'runs to1999-12-31T23:59:59Z,max: '1999-05'to the end of May, and a date-time is just that second. Contiguous periods still partition cleanly, because one ends before the next begins. This also settles the coarse-upper-bound case #973 left out of scope, so the1999-12-31T23:59:59Zworkaround is gone from the docs. Number bins stay half-open: there the filter mismatch costs one boundary value, not a year of records.Changes
lastSecondOf(stored)gives the last second of a date’s period. Deep time ends an average Gregorian year on.NumericFieldbecomes the union ofNumberField(integer/number, bins asFacetRange) andDateField(bins as the newDateFacetRange, with ISO 8601 bounds inclusive at both ends).validateSearchTypereportsunparseable-facet-rangefor a bound the codec cannot read, including a leftover number in seconds.storedFacetRangesgives an adapter a field’s bins as half-open Unix seconds – a date bin’smaxas the first second after its period – and the Typesense adapter compiles and echoes through it. A container test buckets dates on both sides of year 1, so a negative bound reaches Typesense.maxthroughlastSecondOf.[DateRangeBucket!]!, whosemin/maxareISO8601Dateserved at the precision they were declared in (1899, not1899-01-01T00:00:00Z). They go straight intoDateRangeand select exactly the documents the bucket counts.Follow-up to #987.