blob: e46b492564a0883b4a82f734b03b980b17f792b4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
// Utility functions for FTS tests
//
function queryIDS(coll, search, filter, extra, limit) {
var query = {"$text": {"$search": search}};
if (extra)
query = {"$text": Object.extend({"$search": search}, extra)};
if (filter)
Object.extend(query, filter);
var result;
if (limit)
result = coll.find(query, {score: {"$meta": "textScore"}})
.sort({score: {"$meta": "textScore"}})
.limit(limit);
else
result =
coll.find(query, {score: {"$meta": "textScore"}}).sort({score: {"$meta": "textScore"}});
return getIDS(result);
}
// Return an array of _ids from a cursor
function getIDS(cursor) {
if (!cursor)
return [];
return cursor.map(function(z) {
return z._id;
});
}
|