Skip to content

Commit 28da974

Browse files
committed
got ordering to work with the following request parameters:
`curl -H "Content-Type: application/json" -X POST "http://localhost:5984/medic/_design/medic-nouveau/_nouveau/contacts_by_freetext" -d "{\"q\":\"name:asha\",\"sort\":\"-cht_sort_order\",\"limit\":50}"`
1 parent b584506 commit 28da974

File tree

1 file changed

+5
-0
lines changed
  • ddocs/medic-db/medic-nouveau/nouveau/contacts_by_freetext

1 file changed

+5
-0
lines changed

ddocs/medic-db/medic-nouveau/nouveau/contacts_by_freetext/index.js

+5
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ function (doc) {
3636
}
3737
});
3838

39+
var dead = !!doc.date_of_death;
40+
var muted = !!doc.muted;
41+
var order = dead + ' ' + muted + ' ' + idx + ' ' + (doc.name && doc.name.toLowerCase());
42+
index('string', 'cht_sort_order', order, { store: false });
43+
3944
toIndex = toIndex.trim();
4045
if (toIndex) {
4146
index('text', 'default', toIndex, { store: true });

0 commit comments

Comments
 (0)