#community-help

Displaying More Populated Documents First in Typesense Cloud

TLDR Rushil had a question on how to display the most populated documents first in Typesense cloud. Jason suggested creating a new field to set this function and further clarified related inquiries.

Powered by Struct AI
9
15mo
Solved
Join the chat
Sep 21, 2022 (15 months ago)
Rushil
Photo of md5-23d3662ca8a778f4934a53bf33a66f97
Rushil
02:14 AM
👋 Hi everyone! I had a question for typesense cloud, what functions and syntax would i use to display the most populated documents first in any given filter?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
02:16 AM
> most populated documents first in any given filter
Could you elaborate on this with an example? Didn’t quite understand this
Rushil
Photo of md5-23d3662ca8a778f4934a53bf33a66f97
Rushil
06:47 AM
So I have data that has more fields filled out than others, but on loading the documents the data with less fields filled out shows at the beginning. How can i sort it such that the data that is more populated shows first at any point.
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
03:16 PM
I’d recommend creating a new field called “filled_out_fields_count” and setting that when indexing the documents in Typesense, and then you can use that field in the sort_by search parameter
Rushil
Photo of md5-23d3662ca8a778f4934a53bf33a66f97
Rushil
06:48 PM
Yeah that makes sense
06:49
Rushil
06:49 PM
But there is no way without editing that I could do it? Is any feature like that in the pipeline
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
06:50 PM
No we don’t have this feature planned because this is the first time I’ve heard of a use-case like yours!
Rushil
Photo of md5-23d3662ca8a778f4934a53bf33a66f97
Rushil
07:32 PM
Yeah its fairly unique, will implement what you mentioned. In the schema would I have to label the data as sort:true as well?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
07:42 PM
For numeric data types, sort: true is set by default, so you don’t have to explicitly set it