2
votes

I am implementing the object based intelligence framework on MarkLogic and I fail to see which index I am missing now.

I have created objects and use a rest extension to extract objects from the (sensor) data ingested to the endpoint.

The server log says:

2015-08-17 15:46:41.763 Info: cluey-app: Status 500: XDMP-ELEMRIDXNOTFOUND: cts:element-values(xs:QName("obj:id"), (), "collation=http://marklogic.com/collation/codepoint", cts:and-query((cts:collection-query("object"), cts:element-range-query(xs:QName("obj:type"), "=", "sensor", ("collation=http://marklogic.com/collation/"), 1), cts:element-range-query(xs:QName("scc:id"), "=", xs:untypedAtomic("rb-0041"), (), 1)), ())) -- No string element range index for {http://marklogic.com/solutions/obi/object}type http://marklogic.com/collation/

The code block that tries to create the objects is this:

xquery version "1.0-ml";

    import module namespace obj = "http://marklogic.com/solutions/obi/object" at
      "/ext/obi/lib/object-service-lib.xqy",
      "/ext/obi/lib/object-lib.xqy";

    declare namespace sight= "http://klpd.nl/sight";
    declare namespace scc= "http://sensingclues.com/sccs";


    declare variable $source-id external;
    declare variable $result external;
    declare variable $merge external;

    for $object in $result/objects/element()
    let $type := obj:get-type-from-content($object)
    let $existing-object :=
      if ($merge) then
        cts:element-values(xs:QName("obj:id"), (), ("collation=http://marklogic.com/collation/codepoint"), cts:and-query((
          cts:collection-query("object"),
          obj:type-query($type),
          cts:element-range-query(xs:QName("scc:id"), "=", $object//scc:id)
        )))[1]
      else ()
    let $object-id :=
      if ($existing-object) then
        let $detail-id := obj:add-details($existing-object, $object, $source-id,()) (:hk empty workspace-id:)
        return $existing-object
      else
        obj:create-object($object, $source-id)[1]

    return <result id="{$object-id}" type="{$type}"/>
    ', (xs:QName('source-id'), $source-id, xs:QName('result'), $result, xs:QName('merge'), $merge),
    <options xmlns="xdmp:eval"><isolation>different-transaction</isolation></options>)

Indexes in ml-config for this specific task added are:

    <!-- Cluey specific indexes -->
    <range-element-index>
      <scalar-type>string</scalar-type>
      <namespace-uri>http://sensingclues.com/sccs</namespace-uri>
      <localname>id</localname>
      <collation>http://marklogic.com/collation/</collation>
      <range-value-positions>false</range-value-positions>
      <invalid-values>reject</invalid-values>
    </range-element-index>
    <range-element-index>
      <scalar-type>string</scalar-type>
      <namespace-uri>http://sensingclues.com/sccs</namespace-uri>
      <localname>source</localname>
      <collation>http://marklogic.com/collation/</collation>
      <range-value-positions>false</range-value-positions>
      <invalid-values>reject</invalid-values>
    </range-element-index>
    <range-element-index>
      <scalar-type>string</scalar-type>
      <namespace-uri>http://sensingclues.com/sccs</namespace-uri>
      <localname>timestamp</localname>
      <collation>http://marklogic.com/collation/</collation>
      <range-value-positions>false</range-value-positions>
      <invalid-values>reject</invalid-values>
    </range-element-index>

Question:

What index am I missing? Do I use a wrong collation point?

EDIT :

all other element range indexes in ml-config.xml:

    <range-element-index>
      <scalar-type>string</scalar-type>
      <namespace-uri>http://marklogic.com/solutions/obi/source</namespace-uri>
      <localname>dataset</localname>
      <collation>http://marklogic.com/collation/codepoint</collation>
      <range-value-positions>false</range-value-positions>
      <invalid-values>reject</invalid-values>
    </range-element-index>

    <range-element-index>
      <scalar-type>string</scalar-type>
      <namespace-uri>http://purl.org/dc/terms/</namespace-uri>
      <localname>title</localname>
      <collation>http://marklogic.com/collation/codepoint</collation>
      <range-value-positions>false</range-value-positions>
      <invalid-values>reject</invalid-values>
    </range-element-index>

    <range-element-index>
      <scalar-type>string</scalar-type>
      <namespace-uri>http://marklogic.com/solutions/obi/object</namespace-uri>
      <localname>label</localname>
      <collation>http://marklogic.com/collation/codepoint</collation>
      <range-value-positions>false</range-value-positions>
      <invalid-values>reject</invalid-values>
    </range-element-index>

    <range-element-index>
      <scalar-type>string</scalar-type>
      <namespace-uri>http://marklogic.com/solutions/obi/object</namespace-uri>
      <localname>type</localname>
      <collation>http://marklogic.com/collation/codepoint</collation>
      <range-value-positions>false</range-value-positions>
      <invalid-values>reject</invalid-values>
    </range-element-index>

    <range-element-index>
      <scalar-type>string</scalar-type>
      <namespace-uri>http://marklogic.com/solutions/obi/ontology</namespace-uri>
      <localname>objectDefDirectory</localname>
      <collation>http://marklogic.com/collation/codepoint</collation>
      <range-value-positions>false</range-value-positions>
      <invalid-values>reject</invalid-values>
    </range-element-index>

    <range-element-index>
      <scalar-type>dateTime</scalar-type>
      <namespace-uri>http://marklogic.com/solutions/obi/source</namespace-uri>
      <localname>contentDateTime</localname>
      <collation></collation>
      <range-value-positions>false</range-value-positions>
      <invalid-values>reject</invalid-values>
    </range-element-index>

EDIT SOLUTION

Missing index and collation

    <range-element-index>
      <scalar-type>string</scalar-type>
      <namespace-uri>http://marklogic.com/solutions/obi/source</namespace-uri>
      <localname>id</localname>
      <collation>http://marklogic.com/collation/codepoint</collation>
      <range-value-positions>false</range-value-positions>
      <invalid-values>reject</invalid-values>
    </range-element-index>
2
Can you tell me where this is? obj:type-query($type), maybe missing the type index? - Thijs
in ext/obi/lib/object-lib.xqy - Hugo Koopmans

2 Answers

1
votes

What Dave said - my guess is you're running a query on an app server that defaults to the root collation, and thus the element-range-query on obj:type is defaulting to the root collation, but the index is for the codepoint collation.

0
votes

Looks like you're missing an index on "obj:type".

<range-element-index>
  <scalar-type>string</scalar-type>
  <namespace-uri>http://marklogic.com/solutions/obi/object</namespace-uri>
  <localname>type</localname>
  <collation>http://marklogic.com/collation/</collation>
  <range-value-positions>false</range-value-positions>
  <invalid-values>reject</invalid-values>
</range-element-index>