[MarkLogic Dev General] cts:values scoring

William Sawyer wilby.sawyer at gmail.com
Wed Jan 6 15:28:31 PST 2016


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://developer.marklogic.com/pipermail/general/attachments/20160106/1ef16512/attachment.html 


More information about the General mailing list