我正在MarkLogic上实现基于对象的智能框架,但我现在看不到哪个索引。
我创建了对象并使用rest扩展从提取到端点的(传感器)数据中提取对象。
服务器日志说:
2015-08-17 15:46:41.763信息:cluey-app:状态500: XDMP-ELEMRIDXNOTFOUND:cts:element-values(xs:QName(“obj:id”),(), “核对= http://marklogic.com/collation/codepoint”, CTS:和查询((CTS:收集查询( “对象”), 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)),())) - 没有字符串元素范围 {http://marklogic.com/solutions/obi/object}类型的索引 http://marklogic.com/collation/
尝试创建对象的代码块是:
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>)
添加此特定任务的ml-config中的索引是:
<!-- 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>
问题:
我错过了什么指数?我使用错误的校对点吗?
编辑:
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>
编辑解决方案
缺少索引和整理
<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>
答案 0 :(得分:1)
Dave说 - 我的猜测是你在app服务器上运行查询默认为根目录排序,因此对obj:type的元素范围查询默认为根目录排序,但是index用于代码点排序规则。
答案 1 :(得分:0)
看起来你错过了“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>