title: create objects fails ELEMRIDXNOTFOUND
body: <p>I am implementing the object based intelligence framework on MarkLogic and I fail to see which index I am missing now.</p>
  
  <p>I have created objects and use a rest extension to extract objects from the (sensor) data ingested to the endpoint.</p>
  
  <p>The server log says:</p>
  
  <blockquote>
    <p>2015-08-17 15:46:41.763 Info: cluey-app: Status 500:
    XDMP-ELEMRIDXNOTFOUND: cts:element-values(xs:QName("obj:id"), (),
    "collation=<a href="http://marklogic.com/collation/codepoint" rel="nofollow">http://marklogic.com/collation/codepoint</a>",
    cts:and-query((cts:collection-query("object"),
    cts:element-range-query(xs:QName("obj:type"), "=", "sensor",
    ("collation=<a href="http://marklogic.com/collation/" rel="nofollow">http://marklogic.com/collation/</a>"), 1),
    cts:element-range-query(xs:QName("scc:id"), "=",
    xs:untypedAtomic("rb-0041"), (), 1)), ())) -- No string element range
    index for {<a href="http://marklogic.com/solutions/obi/object" rel="nofollow">http://marklogic.com/solutions/obi/object</a>}type
    <a href="http://marklogic.com/collation/" rel="nofollow">http://marklogic.com/collation/</a></p>
  </blockquote>
  
  <p>The code block that tries to create the objects is this:</p>
  
  <pre><code>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 &lt;result id="{$object-id}" type="{$type}"/&gt;
      ', (xs:QName('source-id'), $source-id, xs:QName('result'), $result, xs:QName('merge'), $merge),
      &lt;options xmlns="xdmp:eval"&gt;&lt;isolation&gt;different-transaction&lt;/isolation&gt;&lt;/options&gt;)
  </code></pre>
  
  <p>Indexes in ml-config for this specific task added are:</p>
  
  <pre><code>    &lt;!-- Cluey specific indexes --&gt;
      &lt;range-element-index&gt;
        &lt;scalar-type&gt;string&lt;/scalar-type&gt;
        &lt;namespace-uri&gt;http://sensingclues.com/sccs&lt;/namespace-uri&gt;
        &lt;localname&gt;id&lt;/localname&gt;
        &lt;collation&gt;http://marklogic.com/collation/&lt;/collation&gt;
        &lt;range-value-positions&gt;false&lt;/range-value-positions&gt;
        &lt;invalid-values&gt;reject&lt;/invalid-values&gt;
      &lt;/range-element-index&gt;
      &lt;range-element-index&gt;
        &lt;scalar-type&gt;string&lt;/scalar-type&gt;
        &lt;namespace-uri&gt;http://sensingclues.com/sccs&lt;/namespace-uri&gt;
        &lt;localname&gt;source&lt;/localname&gt;
        &lt;collation&gt;http://marklogic.com/collation/&lt;/collation&gt;
        &lt;range-value-positions&gt;false&lt;/range-value-positions&gt;
        &lt;invalid-values&gt;reject&lt;/invalid-values&gt;
      &lt;/range-element-index&gt;
      &lt;range-element-index&gt;
        &lt;scalar-type&gt;string&lt;/scalar-type&gt;
        &lt;namespace-uri&gt;http://sensingclues.com/sccs&lt;/namespace-uri&gt;
        &lt;localname&gt;timestamp&lt;/localname&gt;
        &lt;collation&gt;http://marklogic.com/collation/&lt;/collation&gt;
        &lt;range-value-positions&gt;false&lt;/range-value-positions&gt;
        &lt;invalid-values&gt;reject&lt;/invalid-values&gt;
      &lt;/range-element-index&gt;
  </code></pre>
  
  <p>Question:</p>
  
  <p>What index am I missing? Do I use a wrong collation point?</p>
  
  <p>EDIT :</p>
  
  <p>all other element range indexes in ml-config.xml:</p>
  
  <pre><code>    &lt;range-element-index&gt;
        &lt;scalar-type&gt;string&lt;/scalar-type&gt;
        &lt;namespace-uri&gt;http://marklogic.com/solutions/obi/source&lt;/namespace-uri&gt;
        &lt;localname&gt;dataset&lt;/localname&gt;
        &lt;collation&gt;http://marklogic.com/collation/codepoint&lt;/collation&gt;
        &lt;range-value-positions&gt;false&lt;/range-value-positions&gt;
        &lt;invalid-values&gt;reject&lt;/invalid-values&gt;
      &lt;/range-element-index&gt;
  
      &lt;range-element-index&gt;
        &lt;scalar-type&gt;string&lt;/scalar-type&gt;
        &lt;namespace-uri&gt;http://purl.org/dc/terms/&lt;/namespace-uri&gt;
        &lt;localname&gt;title&lt;/localname&gt;
        &lt;collation&gt;http://marklogic.com/collation/codepoint&lt;/collation&gt;
        &lt;range-value-positions&gt;false&lt;/range-value-positions&gt;
        &lt;invalid-values&gt;reject&lt;/invalid-values&gt;
      &lt;/range-element-index&gt;
  
      &lt;range-element-index&gt;
        &lt;scalar-type&gt;string&lt;/scalar-type&gt;
        &lt;namespace-uri&gt;http://marklogic.com/solutions/obi/object&lt;/namespace-uri&gt;
        &lt;localname&gt;label&lt;/localname&gt;
        &lt;collation&gt;http://marklogic.com/collation/codepoint&lt;/collation&gt;
        &lt;range-value-positions&gt;false&lt;/range-value-positions&gt;
        &lt;invalid-values&gt;reject&lt;/invalid-values&gt;
      &lt;/range-element-index&gt;
  
      &lt;range-element-index&gt;
        &lt;scalar-type&gt;string&lt;/scalar-type&gt;
        &lt;namespace-uri&gt;http://marklogic.com/solutions/obi/object&lt;/namespace-uri&gt;
        &lt;localname&gt;type&lt;/localname&gt;
        &lt;collation&gt;http://marklogic.com/collation/codepoint&lt;/collation&gt;
        &lt;range-value-positions&gt;false&lt;/range-value-positions&gt;
        &lt;invalid-values&gt;reject&lt;/invalid-values&gt;
      &lt;/range-element-index&gt;
  
      &lt;range-element-index&gt;
        &lt;scalar-type&gt;string&lt;/scalar-type&gt;
        &lt;namespace-uri&gt;http://marklogic.com/solutions/obi/ontology&lt;/namespace-uri&gt;
        &lt;localname&gt;objectDefDirectory&lt;/localname&gt;
        &lt;collation&gt;http://marklogic.com/collation/codepoint&lt;/collation&gt;
        &lt;range-value-positions&gt;false&lt;/range-value-positions&gt;
        &lt;invalid-values&gt;reject&lt;/invalid-values&gt;
      &lt;/range-element-index&gt;
  
      &lt;range-element-index&gt;
        &lt;scalar-type&gt;dateTime&lt;/scalar-type&gt;
        &lt;namespace-uri&gt;http://marklogic.com/solutions/obi/source&lt;/namespace-uri&gt;
        &lt;localname&gt;contentDateTime&lt;/localname&gt;
        &lt;collation&gt;&lt;/collation&gt;
        &lt;range-value-positions&gt;false&lt;/range-value-positions&gt;
        &lt;invalid-values&gt;reject&lt;/invalid-values&gt;
      &lt;/range-element-index&gt;
  </code></pre>
  
  <p>EDIT SOLUTION</p>
  
  <p>Missing index and collation</p>
  
  <pre><code>    &lt;range-element-index&gt;
        &lt;scalar-type&gt;string&lt;/scalar-type&gt;
        &lt;namespace-uri&gt;http://marklogic.com/solutions/obi/source&lt;/namespace-uri&gt;
        &lt;localname&gt;id&lt;/localname&gt;
        &lt;collation&gt;http://marklogic.com/collation/codepoint&lt;/collation&gt;
        &lt;range-value-positions&gt;false&lt;/range-value-positions&gt;
        &lt;invalid-values&gt;reject&lt;/invalid-values&gt;
      &lt;/range-element-index&gt;
  </code></pre>