Hi Ankit,

cts:search() has an option to allow you to pass a cts:order to it ( 
https://docs.marklogic.com/cts:search#options ). You can pass in 
cts:score-order() ( https://docs.marklogic.com/cts:score-order ).

I believe that should make the results come out of cts:search() in the order 
you are expecting.

Best,
Rob

Rob Szkutak
Senior Consultant
MarkLogic Corporation
[email protected]
www.marklogic.com


________________________________________
From: [email protected] 
[[email protected]] on behalf of Ankit Bhardwaj 
[[email protected]]
Sent: Tuesday, April 26, 2016 4:39 AM
To: [email protected]
Subject: [MarkLogic Dev General] Sort cts:search results by cts:score   without 
using expicit loop

Hi,

I want to get results of cts:search data sorted on the basis of cts:score. I am 
using following code -

(
        if ($direction = "descending")
        then
            for $result in cts:search (...)
            order by cts:score($result) descending
            return $result/element()
        else
            for $result in cts:search (...)
            order by cts:score($result) ascending
            return $result/element()
    )[$first-result to $last-result]
Is there any way out of getting results from cts:search in a sorted manner 
itself?

The problem with the current code is that in the case of large data set it 
gives XDMP-EXPNTREECACHEFULL error. Increasing the size of Expanded Tree Cache 
is not an option. So I need to do something in this part only. Any suggestions 
around this?

Thanks,
Ankit Bhardwaj
_______________________________________________
General mailing list
[email protected]
Manage your subscription at:
http://developer.marklogic.com/mailman/listinfo/general
_______________________________________________
General mailing list
[email protected]
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to