From b04a3c4741d72913e5613b5316ef29c6b0982efb Mon Sep 17 00:00:00 2001 From: m5r Date: Wed, 27 Nov 2024 17:27:01 +0100 Subject: [PATCH] got ordering to work with the following request parameters: `curl -H "Content-Type: application/json" -X POST "http://admin:groot@localhost:5984/medic/_design/medic-nouveau/_nouveau/contacts_by_freetext" -d "{\"q\":\"name:asha\",\"sort\":\"-cht_sort_order\",\"limit\":50}"` --- .../medic-nouveau/nouveau/contacts_by_freetext/index.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ddocs/medic-db/medic-nouveau/nouveau/contacts_by_freetext/index.js b/ddocs/medic-db/medic-nouveau/nouveau/contacts_by_freetext/index.js index a322659b62..1b30c2405c 100644 --- a/ddocs/medic-db/medic-nouveau/nouveau/contacts_by_freetext/index.js +++ b/ddocs/medic-db/medic-nouveau/nouveau/contacts_by_freetext/index.js @@ -36,6 +36,11 @@ function (doc) { } }); + var dead = !!doc.date_of_death; + var muted = !!doc.muted; + var order = dead + ' ' + muted + ' ' + idx + ' ' + (doc.name && doc.name.toLowerCase()); + index('string', 'cht_sort_order', order, { store: false }); + toIndex = toIndex.trim(); if (toIndex) { index('text', 'default', toIndex, { store: true });