这个xpath有什么问题,或者Marklogic行为不正常?

这个xpath有什么问题,或者Marklogic行为不正常?,xpath,xquery,marklogic,Xpath,Xquery,Marklogic,我有一个奇怪的问题,当我确定数据存在于Marklogic中时,简单的xpath不返回数据。我可以通过更通用的xpath查看有问题的数据,但不能具体地获得它 有效的xpath: /log:record[log:changes/log:change/@field = "moduleCodes"] => a long sequence of log:record elements with "moduleCodes" field changes xpath没有: /log:record/log

我有一个奇怪的问题,当我确定数据存在于Marklogic中时,简单的xpath不返回数据。我可以通过更通用的xpath查看有问题的数据,但不能具体地获得它

有效的xpath:

/log:record[log:changes/log:change/@field = "moduleCodes"]
=> a long sequence of log:record elements with "moduleCodes" field changes
xpath没有:

/log:record/log:changes/log:change[@field = "moduleCodes"]
=> empty sequence
(我已经让
日志
名称空间定义简洁。)

为了弄清楚发生了什么,我从第一个xpath开始工作,并在此基础上构建:

/log:record[log:changes/log:change/@field = "moduleCodes"]/log:changes/log:change
=> sequence of log:change elements including some with @field = "moduleCodes"
/log:record[log:changes/log:change/@field = "moduleCodes"]/log:changes/log:change[@field]
=> sequence of log:change elements including some with @field = "moduleCodes"
/log:record[log:changes/log:change/@field = "moduleCodes"]/log:changes/log:change[@field = "moduleCodes"]
=> empty sequence
我是不是误解了一些基本的东西?我看不出为什么XPath将谓词放在
log:change
上会返回一个空序列,而其他一切都按照我的预期工作。这让我觉得Marklogic不知怎么搞糊涂了,但我想在开始这样说之前,确保不仅仅是我遗漏了xpath的一个微妙之处

我只是尝试了使用不同字段名的路径。它与我期望的(至少一些)其他值一样工作

我刚刚重新启动了ML集群;没有变化


编辑:

上面所有的XPath在氧气中都能正常工作,所以看起来只有ML的行为是这样的。我尝试将
fn:doc()
添加到所有路径的前面,以防有帮助,但没有任何区别

这里有一个(匿名)记录,我认为应该与所有XPath匹配:

<log:record id="00000001" date="2013-04-14T01:42:02.922+01:00" type="change" xmlns:log="some/namespace/definition">
  <log:head>
     <some-header-info/>
  </log:head>
  <log:changes>
    <log:change field="dateModified">
      <log:old-value>2012-11-06T00:00:00.0000000</log:old-value>
      <log:new-value>2013-03-20T00:00:00.0000000</log:new-value>
    </log:change>
    <log:change field="moduleCodes">
      <log:old-value>
        <log:moduleCodes>
          <log:moduleCodes-value code="AAA"/>
        </log:moduleCodes>
      </log:old-value>
      <log:new-value>
        <log:moduleCodes>
          <log:moduleCodes-value code="AAA"/>
          <log:moduleCodes-value code="BBB"/>
        </log:moduleCodes>
      </log:new-value>
    </log:change>
  </log:changes>
</log:record>

2012-11-06T00:00:00.0000000
2013-03-20T00:00:00.0000000

我尽我所能用6.0-2.3重新创建您的测试,这对我很有用

调试数据库查询时,一种有用的技术是移动内存中的内容。如果它仍然不起作用,则会对数据库查询产生怀疑。当我尝试使用6.0-2.3时,结果似乎是正确的

declare namespace log="some/namespace/definition" ;
document {
<log:record id="00000001" date="2013-04-14T01:42:02.922+01:00" type="change" xmlns:log="some/namespace/definition">
  <log:head>
     <some-header-info/>
  </log:head>
  <log:changes>
    <log:change field="dateModified">
      <log:old-value>2012-11-06T00:00:00.0000000</log:old-value>
      <log:new-value>2013-03-20T00:00:00.0000000</log:new-value>
    </log:change>
    <log:change field="moduleCodes">
      <log:old-value>
        <log:moduleCodes>
          <log:moduleCodes-value code="AAA"/>
        </log:moduleCodes>
      </log:old-value>
      <log:new-value>
        <log:moduleCodes>
          <log:moduleCodes-value code="AAA"/>
          <log:moduleCodes-value code="BBB"/>
        </log:moduleCodes>
      </log:new-value>
    </log:change>
  </log:changes>
</log:record> }
/log:record[log:changes/log:change/@field = "moduleCodes"]/xdmp:path(.)
=>
/log:record

declare namespace log="some/namespace/definition" ;
document {
<log:record id="00000001" date="2013-04-14T01:42:02.922+01:00" type="change" xmlns:log="some/namespace/definition">
  <log:head>
     <some-header-info/>
  </log:head>
  <log:changes>
    <log:change field="dateModified">
      <log:old-value>2012-11-06T00:00:00.0000000</log:old-value>
      <log:new-value>2013-03-20T00:00:00.0000000</log:new-value>
    </log:change>
    <log:change field="moduleCodes">
      <log:old-value>
        <log:moduleCodes>
          <log:moduleCodes-value code="AAA"/>
        </log:moduleCodes>
      </log:old-value>
      <log:new-value>
        <log:moduleCodes>
          <log:moduleCodes-value code="AAA"/>
          <log:moduleCodes-value code="BBB"/>
        </log:moduleCodes>
      </log:new-value>
    </log:change>
  </log:changes>
</log:record> }
/log:record/log:changes/log:change[@field = "moduleCodes"]/xdmp:path(.)
=>
/log:record/log:changes/log:change[2]
在6.0-2.3版本中,这两个版本都返回了我的预期结果

fn:doc("test")/log:record
fn:doc("test")/log:record/log:changes/log:change[2]
以下是ErrorLog.txt文件中的跟踪:

Analyzing path: fn:collection()/log:record[log:changes/log:change/@field = "moduleCodes"]/xdmp:describe(.)
Step 1 is searchable: fn:collection()
Step 2 is searchable: log:record[log:changes/log:change/@field = "moduleCodes"]
Step 3 is unsearchable: xdmp:describe(.)
First 2 steps of path are searchable: fn:collection()/log:record[log:changes/log:change/@field = "moduleCodes"]
Gathering constraints.
 Comparison contributed hash value constraint: log:change/@field = "moduleCodes"
Step 2 predicate 1 contributed 3 constraints: log:changes/log:change/@field = "moduleCodes"
 Comparison contributed hash value constraint: log:change/@field = "moduleCodes"
Step 2 predicate 1 contributed 1 constraint: log:changes/log:change/@field = "moduleCodes"
Step 2 contributed 4 constraints: log:record[log:changes/log:change/@field = "moduleCodes"]
Executing search.
Selected 1 fragment to filter
 xdmp:eval("declare namespace log=&quot;some/namespace/definition&quot; ;&#1...", (), <options xmlns="xdmp:eval"><database>598453498912235799</database><root>/tmp</root><isolati...</options>)
 Analyzing path: fn:collection()/log:record/log:changes/log:change[@field = "moduleCodes"]/xdmp:describe(.)
 Step 1 is searchable: fn:collection()
 Step 2 is searchable: log:record
 Step 3 is searchable: log:changes
 Step 4 is searchable: log:change[@field = "moduleCodes"]
 Step 5 is unsearchable: xdmp:describe(.)
 First 4 steps of path are searchable: fn:collection()/log:record/log:changes/log:change[@field = "moduleCodes"]
 Gathering constraints.
Step 2 contributed 1 constraint: log:record
 Comparison contributed hash value constraint: log:change/@field = "moduleCodes"
 Step 4 predicate 1 contributed 1 constraint: @field = "moduleCodes"
 Step 4 contributed 1 constraint: log:change[@field = "moduleCodes"]
 Comparison contributed hash value constraint: log:change/@field = "moduleCodes"
 Step 4 predicate 1 contributed 1 constraint: @field = "moduleCodes"
 Comparison contributed hash value constraint: log:change/@field = "moduleCodes"
 Step 4 predicate 1 contributed 1 constraint: @field = "moduleCodes"
 Step 4 contributed 1 constraint: log:change[@field = "moduleCodes"]
 Step 3 contributed 1 constraint: log:changes
 Executing search.
 Selected 1 fragment to filter
分析路径:fn:collection()/log:record[log:changes/log:change/@field=“moduleCodes”]/xdmp:description(.)
步骤1可搜索:fn:collection()
步骤2可搜索:log:record[log:changes/log:change/@field=“moduleCodes”]
步骤3不可搜索:xdmp:descripe(.)
路径的前两个步骤是可搜索的:fn:collection()/log:record[log:changes/log:change/@field=“moduleCodes”]
收集约束。
比较贡献的哈希值约束:log:change/@field=“moduleCodes”
步骤2谓词1提供了3个约束:log:changes/log:change/@field=“moduleCodes”
比较贡献的哈希值约束:log:change/@field=“moduleCodes”
步骤2谓词1提供了1个约束:log:changes/log:change/@field=“moduleCodes”
步骤2和步骤4约束:log:record[log:changes/log:change/@field=“moduleCodes”]
正在执行搜索。
选择1个要筛选的片段

xdmp:eval(“declare namespace log=“some/namespace/definition”;…”,(),598453498912235799/tmpWhat data-you-like-fetch精确地获取数据?听起来像是一个ML错误,我建议联系marklogic.com上的支持人员。包括您正在使用的marklogic和OS的确切版本。。
Analyzing path: fn:collection()/log:record[log:changes/log:change/@field = "moduleCodes"]/xdmp:describe(.)
Step 1 is searchable: fn:collection()
Step 2 is searchable: log:record[log:changes/log:change/@field = "moduleCodes"]
Step 3 is unsearchable: xdmp:describe(.)
First 2 steps of path are searchable: fn:collection()/log:record[log:changes/log:change/@field = "moduleCodes"]
Gathering constraints.
 Comparison contributed hash value constraint: log:change/@field = "moduleCodes"
Step 2 predicate 1 contributed 3 constraints: log:changes/log:change/@field = "moduleCodes"
 Comparison contributed hash value constraint: log:change/@field = "moduleCodes"
Step 2 predicate 1 contributed 1 constraint: log:changes/log:change/@field = "moduleCodes"
Step 2 contributed 4 constraints: log:record[log:changes/log:change/@field = "moduleCodes"]
Executing search.
Selected 1 fragment to filter
 xdmp:eval("declare namespace log=&quot;some/namespace/definition&quot; ;&#1...", (), <options xmlns="xdmp:eval"><database>598453498912235799</database><root>/tmp</root><isolati...</options>)
 Analyzing path: fn:collection()/log:record/log:changes/log:change[@field = "moduleCodes"]/xdmp:describe(.)
 Step 1 is searchable: fn:collection()
 Step 2 is searchable: log:record
 Step 3 is searchable: log:changes
 Step 4 is searchable: log:change[@field = "moduleCodes"]
 Step 5 is unsearchable: xdmp:describe(.)
 First 4 steps of path are searchable: fn:collection()/log:record/log:changes/log:change[@field = "moduleCodes"]
 Gathering constraints.
Step 2 contributed 1 constraint: log:record
 Comparison contributed hash value constraint: log:change/@field = "moduleCodes"
 Step 4 predicate 1 contributed 1 constraint: @field = "moduleCodes"
 Step 4 contributed 1 constraint: log:change[@field = "moduleCodes"]
 Comparison contributed hash value constraint: log:change/@field = "moduleCodes"
 Step 4 predicate 1 contributed 1 constraint: @field = "moduleCodes"
 Comparison contributed hash value constraint: log:change/@field = "moduleCodes"
 Step 4 predicate 1 contributed 1 constraint: @field = "moduleCodes"
 Step 4 contributed 1 constraint: log:change[@field = "moduleCodes"]
 Step 3 contributed 1 constraint: log:changes
 Executing search.
 Selected 1 fragment to filter