Handling Empty Searches in Typesense

TLDR Ahmed inquired about Typesense's handling of empty searches. Jason explained the default behavior and suggested controlling the ranking using sort_by.

Photo of Ahmed
Ahmed
Mon, 24 Jan 2022 16:48:56 UTC

Hello, how does Typesense with empty searches? Does it simply return the entire collection sorted by date added? Is there any way I can alter how it deals with empty searches?

Photo of Jason
Jason
Mon, 24 Jan 2022 16:51:52 UTC

By default, for `*` queries, Typesense will sort by the default sorting field if one is mentioned in the collection, otherwise it will fall back to the document insertion order

Photo of Jason
Jason
Mon, 24 Jan 2022 16:52:00 UTC

You can control the ranking using sort_by

Photo of Jason
Jason
Mon, 24 Jan 2022 16:52:15 UTC

More info here: