代码之家  ›  专栏  ›  技术社区  ›  Ravi

限制cts:搜索以设置xml元素的数量

  •  0
  • Ravi  · 技术社区  · 6 年前

    我有一个 cts:query 我想限制我的 CTS:查询 只搜索一些xml元素。在不创建任何字段索引或修改 CTS:查询 作为我的 CTS:查询 非常大..当我这样做的时候

    cts:search((
            //es:raw/wos_dps:REC/wos_dps:static_data/wos_dps:summary/wos_dps:titles/wos_dps:title,
            //es:raw/wos_dps:REC/wos_dps:static_data/ wos_dps:fullrecord_metadata/ wos_dps:abstracts/ wos_dps:abstract
           )
          , 
          $q, 
          ('unfiltered'))[1 to 10]
    

    哪里 $q 是我的 CTS:查询 比如下面的例子。我得到的表达式是不可搜索的..如何做到这一点?…为了完成我的代码,下面是我的 CTS:查询 下面只是一个样本,它更大 CTS:查询 :)

    cts:and-query(
              (
               cts:or-query(
               (
                 cts:near-query(
                  (
                    cts:or-query((
                        cts:word-query("Guideline", ("case-insensitive", "punctuation-insensitive", "whitespace-insensitive", "wildcarded")),
                        cts:word-query("guidelines", ("case-insensitive", "punctuation-insensitive", "whitespace-insensitive", "wildcarded"))
                       )
                      )
                    ,
                    cts:or-query((
                        cts:word-query("clinical", ("case-insensitive", "punctuation-insensitive", "whitespace-insensitive", "wildcarded")),
                        cts:word-query("practice", ("case-insensitive", "punctuation-insensitive", "whitespace-insensitive", "wildcarded")),
                        cts:word-query("adherence", ("case-insensitive", "punctuation-insensitive", "whitespace-insensitive", "wildcarded"))         
                       )
                      )
                  )
                 , 
                 4,
                 ('unordered'))
                 ,
                   cts:near-query((
                    cts:word-query("phase", ("case-insensitive", "wildcarded")),
                    cts:or-query((
                      cts:word-query("0", ("case-insensitive", "wildcarded")),
                      cts:word-query("1", ("case-insensitive", "wildcarded")),
                      cts:word-query("2", ("case-insensitive", "wildcarded")),
                      cts:word-query("3", ("case-insensitive", "wildcarded")),
                      cts:word-query("4", ("case-insensitive", "wildcarded")),
                      cts:word-query("i", ("case-insensitive", "wildcarded")),
                      cts:word-query("ii", ("case-insensitive", "wildcarded")),
                      cts:word-query("iii", ("case-insensitive", "wildcarded")),
                      cts:word-query("iv", ("case-insensitive", "wildcarded"))
                    )))
                   , 
                   0, 
                   ('unordered')),
                 cts:near-query((
                   cts:or-query((
                     cts:word-query("phase2*", ("case-insensitive", "wildcarded")),
                     cts:word-query("phase1*", ("case-insensitive", "wildcarded")),
                     cts:word-query("phase0*", ("case-insensitive", "wildcarded")),
                     cts:word-query("phase4*", ("case-insensitive", "wildcarded")),
                     cts:word-query("phase3*", ("case-insensitive", "wildcarded")),
                     cts:word-query("phasei*", ("case-insensitive", "wildcarded")),
                     cts:word-query("phaseii*", ("case-insensitive", "wildcarded")),
                     cts:word-query("phaseiii*", ("case-insensitive", "wildcarded")),
                     cts:word-query("phaseiv*", ("case-insensitive", "wildcarded"))
                   )),
                   cts:or-query((
                    cts:word-query("trail*", ("case-insensitive", "wildcarded")),
                    cts:word-query("study", ("case-insensitive", "wildcarded")),
                    cts:word-query("studies*", ("case-insensitive", "wildcarded"))
                   ))
                   ), 
                   1, 
                   ('unordered')),
               )
              ),
               cts:collection-query(("http://xxxx/entity/wos/article")),
               cts:element-attribute-value-query((xs:QName(xs:QName("wos_dps:pub_info"))),
                      (xs:QName("wos_dps:pubyear")),
                      "2017")
              )
              , 
              ("unordered"))
    
    1 回复  |  直到 6 年前
        1
  •  4
  •   Rob S.    6 年前

    为了回答你的核心问题,你可以使用 cts:element-query 将查询限制为特定元素。

    您的查询有很大的优化空间。我不认为它会针对大型数据集进行扩展。我强烈推荐你有任何与你联系的MARKLogic资源,看看你想做什么,评估你的方法。