我试图通过查询分配策略将Marklogic 9分层。我在"Documents“数据库中创建了两个层(作为分区),分区名称如下:
在数据库中,文档存储为JSON,我希望根据文档的do "DYil“属性对它们进行分层。
存在于db中的示例JSON文档:
{
"Yerlesim": "Izmir",
"Ad": "AAA",
"@timestamp": "2018-06-02T21:16:23.647Z",
"SoyAd": "BBB",
"@version": "1",
"DYil": "2010-01-01",
"host": "dhcppc6",
"Yas": 8,
"type": "testA",
}数据库的配置是根据Marklogic文档完成的,以下说明如下:
为分区Part2分配的查询是:
<partition-query-properties xmlns="http://marklogic.com/manage/partition-query/properties">
<partition-number>2</partition-number>
<query>
<cts:json-property-range-query operator="<" xmlns:cts="http://marklogic.com/cts">
<cts:property>DYil</cts:property>
<cts:value xsi:type="xs:date" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">1960-01-01</cts:value>
</cts:json-property-range-query>
</query>
</partition-query-properties>我可以看到,通过调用http://localhost:8002/manage/v2/databases/Documents/partition-queries,通过rest正确地将查询分配给分区。
但是,当我将数据加载到Marklogic时,所有数据都被加载到默认分区中,即使强制重新平衡器工作,也会保持在默认分区中。
Xquery控制台查询是:
cts:search(fn:collection(), cts:json-property-range-query("DYil", "<", xs:date("1960-01-01")), (), (), ts:partition-forests(xdmp:database("Documents"),"Part1"))我使用Marklogic中建议的cts:json-property-range-query("DYil", "<", xs:date("1960-01-01"))代码将cts:query转换为<root>{cts:json-property-range-query("DYil", "<", xs:date("1960-01-01"))}</root>/node()格式。
错误日志中没有失败的日志记录,因此我怀疑分配的查询存在问题,但无法找到问题。
发布于 2018-06-06 00:16:44
WRT查询匹配,这是一些代码,我试着检查了一次。在content中运行,它将检查分区查询并查看每个查询匹配的数量。
xquery version "1.0-ml";
declare namespace ts = 'http://marklogic.com/xdmp/tieredstorage';
let $xpath := "
declare namespace ts = 'http://marklogic.com/xdmp/tieredstorage';
/ts:partition-query
"
for $pq in xdmp:eval ($xpath, (), <options xmlns='xdmp:eval'><database>{xdmp:schema-database()}</database></options>)
let $query := cts:query ($pq/ts:query/*)
let $number := $pq/ts:partition-number/fn:data ()
let $matched := xdmp:estimate (cts:search (/, $query))
return ('query is: ', $pq, 'cts q is: ', $query, 'p# is: ', $number, '# docs matched is:', $matched)https://stackoverflow.com/questions/50661793
复制相似问题