简体   繁体   English

search:在marklogic中搜索显示的意外行为

[英]Unexpected behavior shown by search:search in marklogic

I am using search:search for searching the below kind of structure: 我正在使用search:search搜索以下类型的结构:

search:search(
  "",
  <options>
    <additional-query>
      {
        cts:and-query((
            cts:collection-query("A"),
            cts:not-query(cts:collection-query("B")),
            cts:not-query(cts:collection-query("C")),
            cts:and-query((
                cts:element-value-query(
                  xs:QName("uri"),
                  cts:search(collection("A"),
                    cts:element-value-query(xs:QName("uri"),
                      cts:search(collection("B"),
                        cts:element-value-query(xs:QName("uri"),
                          cts:search(collection("C"),cts:word-query("Hello"))/fn:base-uri()
                        )
                      )/fn:base-uri()
                    )
                  )/fn:base-uri()
                ),
                dls:documents-query()
            ))
        ))
      }
    </additional-query>
  </options>,1,10)

It gives 0 result. 结果为0。

However if I try this it gives required result 但是,如果我尝试这样做,它会提供所需的结果

let $a :=
  cts:search(collection("A"),
    cts:element-value-query(xs:QName("uri"),
      cts:search(collection("B"),
        cts:element-value-query(xs:QName("uri"),
          cts:search(collection("C"),cts:word-query("Hello"))/fn:base-uri()
        )
      )/fn:base-uri()
    )
  )/fn:base-uri()
return
  search:search(
    "",
    <options>
      <additional-query>
        {
          cts:and-query((
              cts:collection-query("A"),
              cts:not-query(cts:collection-query("B")),
              cts:not-query(cts:collection-query("C")),
              cts:and-query((
                  cts:element-value-query(
                    xs:QName("uri"),
                    $a
                  ),
                  dls:documents-query()
              ))
          ))
        }
      </additional-query>
    </options>, 1, 10)

It solves the problem where some section is taken out and then passed in search:search options. 它解决了将某些部分取出然后传递给search:search选项的问题。 Please look into it and help 请调查并提供帮助

You can't embed a cts:query directly in search:options . 您不能将cts:query直接嵌入search:options

Instead, try: 相反,请尝试:

<search:options>
<search:additional-query>{...your cts:query here ...}</search:additional-query>
</search:options>

For more information, see: 有关更多信息,请参见:

http://docs.marklogic.com/guide/rest-dev/appendixb#id_98507 http://docs.marklogic.com/guide/rest-dev/appendixb#id_98507

Also, if you want to use a subquery to retrieve values for use as criteria, you should create range indexes on the elements that are the source of the values and the target of the query and use a cts:values() lexicon lookup. 另外,如果要使用子查询来检索用作标准的值,则应在作为值源和查询目标的元素上创建范围索引,并使用cts:values()词典查找。 For more information, see: 有关更多信息,请参见:

http://docs.marklogic.com/cts:values http://docs.marklogic.com/cts:values

Hoping that helps, 希望能有所帮助,

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM