marklogic,如何在文档属性上创build范围

<?xml version="1.0" encoding="UTF-8"?> <prop:properties xmlns:prop="http://marklogic.com/xdmp/property"> <publicationDate type="string" xmlns="http://marklogic.com/xdmp/json/basic">2015-03-30</publicationDate> <identifier type="string" xmlns="http://marklogic.com/xdmp/json/basic">2629</identifier> <posix type="string" xmlns="http://marklogic.com/xdmp/json/basic">nobs</posix> </prop:properties> 

我有一个具有上述这些属性的文档。
我想按“PublicationDate”过滤…
我尝试使用“字段”和“字段范围索引”和“元素范围索引”,但我没有find指定此属性的语法(XML或JSON)?

有谁知道这个语法?

亲切的问候

除了提供示例的答案外,请记住元素publicationDate 不在名称空间http://marklogic.com/xdmp/property中。因此,您的索引configuration应该具有json /基本定义为每个元素和引用它作为一个XS:QName不应该引用“道具:”..

试图弄清楚你的索引是否正确? 您始终可以从查询控制台中尝试cts:values() ,并在代码中使用它之前validation您的索引是否在您期望的位置。

经过多次试验,这似乎工作得很好(MarkLogic 8.0-3):

没有“字段”(其中wmhttp://marklogic.com/xdmp/json/basic ):

 qb.propertiesFragment(qb.value(qb.element(wm,'publicationDate'),'2015-03-30')) 

是好的,但以下产生相同的错误(没有元素范围索引…)

 qb.propertiesFragment(qb.range(qb.element(wm,'publicationDate'), '>=' ,'2015-03-01')) 

使用“Field”( wm:publicationDatewm在Path命名空间中,WITHOUT /vm:properties/ before …),以下方法似乎可以正常工作:-)))

  • qb.propertiesFragment(qb.value(qb.field("properties_publicationDate"),'2015-03-30'))
  • qb.propertiesFragment(qb.range(qb.field("properties_publicationDate"), '>=' ,'2015-03-01'))

我想你正在寻找cts:properties-query

 cts:properties-query( cts:element-range-query( xs:QName("my:publicationDate"),">", current-dateTime() - xs:dayTimeDuration("P1D")))) 

此示例假定prop:publicationDate上的范围索引,并且还要注意,这是假定MarkLogic 7或更低版​​本。 在MarkLogic 8中,此查询的名称似乎已更改为cts:properties-fragment-query

在node.js中,使用查询生成器,可以实现类似的function:

 db.documents.query( qb.where( qb.fragmentScope('properties'), qb.propertiesFragment( qb.range('publicationDate', '>', ... ) ) ) )