Hi Will,

The scores are used for the truncate=N and other options that use a cts:query.  
In those cases, the score will be used to find the top n fragments to 
limit|skip|sample|truncate.

If you want relevance order, I believe you have to do a cts:search.

-Danny

From: [email protected] 
[mailto:[email protected]] On Behalf Of William Sawyer
Sent: Wednesday, January 06, 2016 3:29 PM
To: MarkLogic Developer Discussion
Subject: [MarkLogic Dev General] cts:values scoring

I have a fact fragment created in the database every time an article is viewed, 
 for example:

<fact>
   <doc-id>12345</doc-id>
   <type>read</type>
   <user>userIdHere</user>
   <date>dateTimeHere</date>
</fact>

I am wanting to display a distinct list of the most recent viewed documents.  I 
found the documentation for cts:values has options for scoring so I got really 
excited about using cts:values with a date range query with linear slope 
scoring to produce both a distinct list ordered by most recent.

Example:
cts:values(
            cts:element-reference(xs:QName('doc-id'), 
("type=string","collation=http://marklogic.com/collation/";)),
            (),
            (
              "limit=6",
             "descending",
             "score-logtfidf"
            ),
            cts:and-query((
                        cts:element-range-query(xs:QName('date'), "<=", 
fn:current-dateTime(), ("score-function=reciprocal", "slope-factor=2"), 16),
                        cts:element-range-query(xs:QName('user'), "=", 
"currentUser", "collation=http://marklogic.com/collation/";),
                        cts:element-range-query(xs:QName('type'), '=', "read", 
"collation=http://marklogic.com/collation/";)
            ))
)

The problem is cts:values always returns the values in item order or frequency 
order. There is no option to use score order, which makes me ask the question 
why can you specify how it scores?  I know there are other ways to get my 
desired result.  But it would be a really nice feature to allow cts:values to 
return in score order.

Thanks,
-Will


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

Reply via email to