【问题标题】:Marklogic Property Search - XML Element arrayMarklogic 属性搜索 - XML 元素数组
【发布时间】:2015-08-24 02:09:49
【问题描述】:

这是 Marklogic 中文档的属性文件

<?xml version="1.0" encoding="UTF-8"?>
<prop:properties xmlns:prop="http://marklogic.com/xdmp/property">
  <type type="string" xmlns="http://marklogic.com/xdmp/json/basic">document</type>
  <project type="string" xmlns="http://marklogic.com/xdmp/json/basic">Eagle</project>
  <fileroom type="string" xmlns="http://marklogic.com/xdmp/json/basic">Fileroom3</fileroom>
  <documentTitle type="string" xmlns="http://marklogic.com/xdmp/json/basic">HadoopOperations</documentTitle>
  <uploadDate type="string" xmlns="http://marklogic.com/xdmp/json/basic">2015-08-21T12:45:19.138Z</uploadDate>
  <lastModified type="string" xmlns="http://marklogic.com/xdmp/json/basic">2015-08-21T12:45:19.138Z</lastModified>
  <numPages type="number" xmlns="http://marklogic.com/xdmp/json/basic">11</numPages>
  <users type="array" xmlns="http://marklogic.com/xdmp/json/basic">
    <item type="string">mreviewer1@merrill.com</item>
    <item type="string">madmin1@merrill.com</item>
  </users>
  <cpf:processing-status xmlns:cpf="http://marklogic.com/cpf">done</cpf:processing-status>
  <cpf:property-hash xmlns:cpf="http://marklogic.com/cpf">77ecfa8e87a5097e29b4d9846e131a67</cpf:property-hash>
  <cpf:last-updated xmlns:cpf="http://marklogic.com/cpf">2015-08-21T18:15:19.333+05:30</cpf:last-updated>
  <cpf:state xmlns:cpf="http://marklogic.com/cpf">http://marklogic.com/states/converted</cpf:state>
  <lnk:link from="/Eagle/Fileroom3/HadoopOperations_pdf_parts/" to="/Eagle/Fileroom3/HadoopOperations.pdf" rel="source" rev="conversion" strength="strong" xmlns:lnk="http://marklogic.com/cpf/links"/>
  <lnk:link from="/Eagle/Fileroom3/HadoopOperations_pdf.xhtml" to="/Eagle/Fileroom3/HadoopOperations.pdf" rel="source" rev="conversion" strength="strong" xmlns:lnk="http://marklogic.com/cpf/links"/>
  <cpf:self xmlns:cpf="http://marklogic.com/cpf">/Eagle/Fileroom3/HadoopOperations.pdf</cpf:self>
  <prop:last-modified>2015-08-21T18:15:23+05:30</prop:last-modified>
</prop:properties>

我想写一个查询,我需要在其中找到users 属性具有“madmin1@merrill.com”的文档。

db.documents.query(
        qb.where(
                qb.directory(directories),
                qb.propertiesFragment(
                        qb.value(
                                qb.element(
                                        qb.qname("http://marklogic.com/xdmp/json/basic", "users")
                                ),
                                qb.term("admin.merrill.com")
                        )
                )
        ).withOptions({
            queryPlan: true,
            metrics:true,
            debug:true})
).result(function(response){
    console.log(response);
});

输出:

    [ { 'snippet-format': 'snippet',
    total: 0,
    start: 1,
    'page-length': 10,
    results: [],
    plan: { 'query-plan': [Object] },
    report: '(cts:search(fn:collection(), cts:and-query((cts:directory-query("/Eagle/Fileroom1/", "1"), cts:properties-fragment-query(cts:element-value-query(fn:QName("http://marklogic.com/xdmp/json/basic","users"), "admin.merrill.com", ("lang=en"), 1))), ()), ("unfiltered",cts:score-order("descending")), 1))[1 to 10]',
    metrics: 
     { 'query-resolution-time': 'PT0.015S',
       'snippet-resolution-time': 'PT0S',
       'total-time': 'PT0.172S' } } ]

但是得到空数组。请帮助更正此查询。

【问题讨论】:

    标签: marklogic


    【解决方案1】:

    您正在搜索admin.merrill.com,而您说要查找madmin1@merrill.com。接下来,您正在搜索 jbasic:users 元素,但通过您的方法,您将寻找与该元素的完整字符串值匹配的值,其中包括多个邮件地址。

    我建议为jbasic:users/jbasic:item 添加路径范围索引(确保也添加命名空间),并将其用于匹配。您需要切换到路径范围查询以利用索引。

    这也可以提高性能。范围查询通常比值查询执行得更好。

    HTH!

    【讨论】:

      【解决方案2】:

      我相信它是 qb.properties()不是 qb.propertiesFragment()

      来源:https://docs.marklogic.com/8.0/guide/node-dev/search

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2013-04-24
        • 1970-01-01
        • 2022-08-02
        • 1970-01-01
        • 2015-02-06
        • 2014-02-15
        • 1970-01-01
        相关资源
        最近更新 更多