Hi! I have the following problem, hoping any one o...
# community-help
p
Hi! I have the following problem, hoping any one of you encountered this before and is able to help: • We have a collection with multiple sort enabled fields (about 120 fields in total). Those fields are called
order_when_occasion_X
, used for sorting the collection in case it's viewed in the context of a certain occasion. However, although the values (int32) for the fields are (or seem to be) set correctly, sorting doesn't work as expected; • Example: we have field
order_when_occasion_594120
, with values 100, 95, 90, 80 (2x), 75. When adding ``"sort_by": "order_when_occasion_594120:desc"` to our query, the result is sorted
95, 90, 100, 80, 75, 80
(see screenshot) Did anyone encounter this before? Any help would be welcome!
f
Could you post the full request? You can find it under the Network tab on your Browser's developer tools.
p
Yes, please find query and response (sorted like 95, 90, 100, 80, etc) below:
Copy code
// QUERY
curl -s "https://***.<http://a1.typesense.net:443/multi_search|a1.typesense.net:443/multi_search>" \
  -H "X-TYPESENSE-API-KEY: ***" \
  -H "Content-Type: application/json" \
  -d '{
    "use_cache": false,
    "searches": [{
      "collection": "entries_prod",
      "q": "*",
      "query_by": "title", 
      "filter_by": "enabled:true && siteId:3 && filter_occasion.lvl0:`Bedrijfsuitje`",
      "sort_by": "order_when_occasion_594120:desc,dateUpdated:desc",
      "include_fields": "id,order_when_occasion_594120,dateUpdated,title"
    }]
  }'
Copy code
// RESPONSE:
{"results":[{"facet_counts":[],"found":61,"hits":[{"document":{"dateUpdated":"1714136533","id":"3_d0568f66-cf4d-4854-8cd9-39f14a6a427f","order_when_occasion_594120":95,"title":"Ontmasker de Saboteur"},"highlight":{},"highlights":[]},{"document":{"dateUpdated":"1629398302","id":"3_855efe03-36c8-45bf-a3cd-61db63efc512","order_when_occasion_594120":90,"title":"PubQuiz Diner"},"highlight":{},"highlights":[]},{"document":{"dateUpdated":"1627901503","id":"3_e791206f-3fda-4a0d-bdd2-430146e39915","order_when_occasion_594120":100,"title":"PubQuiz"},"highlight":{},"highlights":[]},{"document":{"dateUpdated":"1757422261","id":"3_7364a21f-c72c-46fe-a747-b9adb5115f9a","order_when_occasion_594120":80,"title":"De Alleskunner - Indoor"},"highlight":{},"highlights":[]},{"document":{"dateUpdated":"1738924193","id":"3_6f40d7ec-00c2-4f6d-a231-84ad09dee701","order_when_occasion_594120":75,"title":"90s / 00s Quiz"},"highlight":{},"highlights":[]},{"document":{"dateUpdated":"1714396056","id":"3_760d4eff-f728-463b-af59-4418fd1e13a2","order_when_occasion_594120":80,"title":"Escape Game: Niets is wat het Lijkt"},"highlight":{},"highlights":[]},{"document":{"dateUpdated":"1726739204","id":"3_ee8231ba-2f08-42a4-ae24-491d73730919","order_when_occasion_594120":75,"title":"Ranking the Company Dinerspel"},"highlight":{},"highlights":[]},{"document":{"dateUpdated":"1714395087","id":"3_628cbe05-3eea-44af-bb84-a2514064c9bd","order_when_occasion_594120":75,"title":"Ik hou van Holland DinerQuiz"},"highlight":{},"highlights":[]},{"document":{"dateUpdated":"1655300298","id":"3_a55009a9-b6c1-4293-8a8e-d73696c7f42a","order_when_occasion_594120":85,"title":"Robinson Uitje"},"highlight":{},"highlights":[]},{"document":{"dateUpdated":"1641991072","id":"3_5cdd4856-1862-4dee-92e6-813b8f03a373","order_when_occasion_594120":85,"title":"Workshop Happy Painting"},"highlight":{},"highlights":[]}],"out_of":132,"page":1,"request_params":{"collection_name":"entries_prod","first_q":"","per_page":10,"q":"*"},"search_cutoff":false,"search_time_ms":1}]}
It's Typesense 0.26, BTW.
k
0.26 is a very old version. I recommend using v29
p
That fixed it!
🙌 1