Sorting WP Posts Alphabetically with Typesense
TLDR Adam wanted to sort WP posts alphabetically by last name. Jason suggested using sort_by
parameter with Typesense, which worked successfully.
2
2
Jun 08, 2023 (6 months ago)
Adam
03:27 PMdefault_sorting_field
of the post’s date converted to int32 by strtotime
. however, I know the question will come up in a department meeting - is there any way to convert the “last name” field (which is obviously a string) into an integer which would allow me to list the results alphabetically when they’re initially fetched? so - does anyone know how to create an integer out of a string which would allow the documents to be ordered from the outset as if they were in alphabetical rather than date order? I fully admit that this is an odd questionJason
04:47 PMInstead of using the
default_sorting_field
you can set a default sort_by
field as a search parameter to use the name field like this:sort_by: text_match:desc,last_name:desc
1
Adam
05:24 PMJason
05:25 PMAdam
05:27 PMAdam
05:38 PM1
Adam
06:10 PM1
1
Typesense
Indexed 3015 threads (79% resolved)
Similar Threads
Resolve Facets and Sorting Issues with Typesense
Ethan needed assistance with getting all facet values and sorting results by date using Typesense. Jason provided guidance on how to use Typesense properties to accomplish these tasks, and resolved issues related to specific use-cases provided by Ethan and Rushil.
Typesense Performance with Large Datasets & Custom Sort
krok inquires about Typesense's performance on large datasets and custom sorting. Kishore Nallan explains that Typesense is optimized for this scenario using pagination and text relevance.
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.