
cts.tripleRangeQuery( subject as (String | Number | Boolean | null | Array | Object)[], predicate as (String | Number | Boolean | null | Array | Object)[], object as (String | Number | Boolean | null | Array | Object)[], [operator as String[]], [options as String[]], [weight as Number?] ) as cts.tripleRangeQuery
  Returns a 
  cts.query
  matching triples with a
  triple index entry equal to the given values. Searches with the
  cts.tripleRangeQuery
  constructor require the triple index;
  if the triple index is not configured, then an exception is thrown.
If you want to constrain on a range of values, you can combine multiple
  cts.tripleRangeQuery
  constructors together
  with 
  cts.andQuery
  or any of the other composable
  cts.query
  constructors.
If neither "cached" nor "uncached" is present, it specifies "cached".
"score-function=linear" means that values that are further away from the bounds will score higher. "score-function=reciprocal" means that values that are closer to the bounds will score higher. The functions are scaled appropriately for different types, so that in general the default slope factor will provide useful results. Using a slope factor greater than 1 gives distinct scores over a smaller range of values, and produces generally higher scores. Using a slope factor less than 1 gives distinct scores over a wider range of values, and produces generally lower scores.
declareUpdate();
const sem = require("/MarkLogic/semantics.xqy");
// insert a couple of triples
// make sure the triple index is enabled on the database
const a = sem.rdfInsert(
  sem.triple(sem.iri("http://example.com/ns/directory#m"),
             sem.iri("http://example.com/ns/person#firstName"),
             "Mark"),
  "override-graph=test1");
const b = sem.rdfInsert(
  sem.triple(sem.iri("http://example.com/Mark"),
             sem.iri("http://example.com/ns/person#age"),
             37),
  "override-graph=test1");
const res = new Array();
res.push(a);
res.push(b);
res;
 =>
 ["/triplestore/a805aaab9109e05f.xml", "/triplestore/d58262c00c3ab97f.xml"]
******
// find all documents that have an embedded triple matching Mark-less-than-50
//
// make sure the triple index is enabled on the database
const sem = require("/MarkLogic/semantics.xqy");
const query =
  cts.tripleRangeQuery(
    sem.iri("http://example.com/Mark"),
    sem.iri("http://example.com/ns/person#age"),
    50,
    "<");
const res = [];
for (let x of cts.search(query)) {
        res.push(x.xpath("//sem.triple"));
};
res;
=>
[
"<sem:triple xmlns:sem="http://marklogic.com/semantics">
  <sem:subject>http://example.com/Mark</sem:subject>
  <sem:predicate>http://example.com/ns/person#age</sem:predicate>
  <sem:object
    datatype="http://www.w3.org/2001/XMLSchema#integer">37</sem:object>
</sem:triple>"
]