#community-help

Prioritizing and Sorting Document Searches by Specific Fields

TLDR Robert inquired on sorting document searches by specific fields. Jason advised on using 'sort_by' for ranking, addressed 'per_page' limit's application, and confirmed unsupported "optional filtering".

Powered by Struct AI
9
27mo
Solved
Join the chat
Oct 07, 2021 (27 months ago)
Robert
Photo of md5-a0aba3e46685345ae57c342a8130989f
Robert
04:28 PM
How can I search for some documents by a specific keyword and have documents with a specific value for a field be more important (rank higher) than the rest? For example we are searching users but want to prioritize the badge verified ones
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
04:50 PM
Robert If you set verified as an integer, you can then use it in the sort_by parameter like this:

sort_by: verified:desc,_text_match:desc
Robert
Photo of md5-a0aba3e46685345ae57c342a8130989f
Robert
05:07 PM
When does ‘per_page’ limit apply? Before or after documents are sorted?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
05:08 PM
After
Robert
Photo of md5-a0aba3e46685345ae57c342a8130989f
Robert
05:08 PM
thanks
05:42
Robert
05:42 PM
Can you sort_by something like field1:32:desc ? Meaning the value 32 for that field would be rank 1, if it was found based on the query/keyword?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
05:57 PM
No it's not possible to do that. You're referring to what's called "optional filtering" which we plan to support in the future
05:57
Jason
05:57 PM
Could you create a Github issue for this?
Oct 08, 2021 (27 months ago)
Robert
Photo of md5-a0aba3e46685345ae57c342a8130989f
Robert
09:31 AM
thanks for letting me know

Typesense

Lightning-fast, open source search engine for everyone | Knowledge Base powered by Struct.AI

Indexed 3005 threads (79% resolved)

Join Our Community

Similar Threads

Understanding and Adjusting Query Parameter Weights

John needed help understanding default weights, manipulating weights, and sorting by weight in query parameters. Jason educated on default weights, sorting mechanism, and also suggested using buckets for sorting based on custom fields.

3

21
19mo
Solved

Methods for Fetching, Querying, and Modifying Collections in Typesense

Bill inquired about performing OR queries, querying empty arrays and modifying collections in Typesense. Kishore Nallan explained the current limitations and provided workarounds and recommendations for each case. The conversation also touched upon the usage of cache in Typesense and the workings of the _eval function.

5

52
10mo
Solved

Discussing Limits on Sort_by Fields

James asked about the limit on `sort_by` fields. Jason clarified that the limit is for a single search query and that you can use more fields across various searches.

1

3
17mo
Solved

Document Weighting and Sorting Discussion

SamHendley asked how to weight a document based on age and offered a sorting method. Jason clarified the method and suggested an RC for use. SamHendley tested and confirmed the solution. User Kishore Nallan assisted when an error occurred with a new feature.

1

30
11mo

Adjusting Text Match Score Calculation in TypeSense

Johannes wanted to modify the Text Match Score calculation in TypeSense to improve search results returns. With counsel from Jason and Kishore Nallan, various solutions were proposed, including creating a Github issue, attempting different parameters, and updating Docker to a new version to resolve the matter.

3

48
19mo