0

我们在客户和计费集合上启用了双时域,并且在客户和计费集合的最新集合中有一个客户“123456”。我们正在尝试使用选项文件从“客户”集合中提取客户的最新文档。

下面是我们编写的选项文件。

{
"options": 
  {
  "search-option": "unfiltered",
  "additional-query":[
          "<collection-query xmlns='http://marklogic.com/cts'>
          <uri>customer</uri>
          </collection-query>"
          ],
  "additional-query":[
          "<collection-query xmlns='http://marklogic.com/cts'>
          <uri>latest</uri>
          </collection-query>"
          ],
  "constraint": [
          { 
          "name": "CustomerId",
          "range": 
                         {
          "type": "xs:string",
          "collation" : "http://marklogic.com/collation/codepoint",
          "element": {"name": "CustomerId" }
                         }
          }
          ],
"extract-document-data": 
          {
          "selected": "exclude",
          "extract-path": [ "/envelope/instance/Customer" ]
          }
  }
}

当我们尝试下面的代码时,文档仍然来自客户和计费集合。

fn.head(search.search('CustomerId:123456', 
SearchOptions.firstChild)).xpath('search:result/search:extracted/data()', 
{'search': 'http://marklogic.com/appservices/search'});

上述查询中的 SearchOptions 是选项文件。

我们的理解是“附加查询”将应用 AND 条件,但看起来我们的理解存在一些差距。

如何在选项文件中应用 AND 条件以仅从“客户”集合中提取最新文档。

提前致谢!

4

1 回答 1

1

您可以使用:

"additional-query":[
      "<collection-query xmlns='http://marklogic.com/cts'>
      <uri>customer</uri>
      </collection-query>",

      "<collection-query xmlns='http://marklogic.com/cts'>
      <uri>latest</uri>
      </collection-query>"
      ],

默认情况下,它们被包装在一个和查询中(在顶层)。

于 2019-03-25T14:03:54.007 回答