Skip to content
This repository was archived by the owner on Oct 5, 2020. It is now read-only.

Commit 2dc2d4b

Browse files
committed
Optimize the similar extension
1 parent eb89644 commit 2dc2d4b

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

app/templates/rest-api/ext/extsimilar.xqy

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,15 @@ function ext:post(
4343
let $content :=
4444
if (exists($uri)) then
4545
json:to-array(
46-
(
47-
for $doc in cts:search(collection(), cts:and-query(($collection-q,cts:similar-query(doc($uri)))))
48-
let $similar-uri := xdmp:node-uri($doc)
49-
where $similar-uri != $uri
50-
return $similar-uri
51-
)[1 to $limit]
46+
cts:uris(
47+
(),
48+
("limit="||$limit),
49+
cts:and-query((
50+
cts:not-query(cts:document-query($uri)),
51+
$collection-q,
52+
cts:similar-query(doc($uri))
53+
))
54+
)
5255
)
5356
else json:array()
5457
let $response := json:object()

0 commit comments

Comments
 (0)