Conversation
- Add a per-type tieBreak, appended after the sort the request and queryDefaults settled on; terms on a field already sorted on are skipped - Leave queries without a sort to the engine鈥檚 default order, and facet-only queries without a tie-break - Reject a tie-break on a non-sortable field, or one longer than two terms, when the schema is built - Reject more than three sort terms in the Typesense compiler, naming them - Pin the order of a block of equal dates across pages and a rebuild against a real Typesense
This branch has not been deployed
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.
Sorted by date, all datasets in a catalog registered at once share a
datePosted, and Typesense returns such ties in insertion order. A reindex inserts them in a different order, so a client paging through the block can see a dataset twice or miss one.A search type can now declare a tie-break in its GraphQL options:
queryDefaultssettled on. A term on a field already sorted on is skipped.defaultSortingField). To break ties there too, set a default sort inqueryDefaults.perPage: 0) get no tie-break.sortable(Typesense has no sort index for it) and one longer than two terms (Typesense sorts on three at most, and one is the primary sort).queryDefaultspolicy that sets two.An integration test writes six documents with the same date, pages through them, rebuilds in reverse insertion order and gets the same order both times. Without the tie-break the rebuild does reshuffle them.
Not fully deterministic. Datasets with the same title still come back in storage order. A unique final key would need a sortable copy of the id in every collection, because Typesense can鈥檛 sort on
id(tested on 30.2: a declaredidfield is dropped, andsort_by=idfails). We decided the extra field and reindex aren鈥檛 worth it for rare exact title ties.Fix #866