简体   繁体   English

如何根据Marklogic Server中的命名空间进行搜索?

[英]How to search according to namespaces in Marklogic Server?

Suppose I am having some xml documents with one namespace(http://www.marklogic.com) and another set of xml documents with another namespace(http://www.mynamespce.com). 假设我有一些带有一个命名空间的xml文档(http://www.marklogic.com)和另一组带有另一个命名空间的xml文档(http://www.mynamespce.com)。 Now I want to search in only those xml documents which are having http://www.marklogic.com namespace. 现在我想只搜索那些具有http://www.marklogic.com命名空间的xml文档。 How can I do this ? 我怎样才能做到这一点 ?

You don't say how you are searching, but if you are calling search:search you can set the searchable-expression option to the root element of the documents, including the namespace. 您没有说出如何搜索,但如果您正在调用search:search您可以将searchable-expression选项设置为文档的根元素,包括命名空间。

declare variable $query as xs:string external ;
search:search(
  $query,
  <options xmlns="http://marklogic.com/appservices/search">
    <searchable-expression
     xmlns:ns1="http://test/namespace/1">/ns1:doc</searchable-expression>
  </options>)

http://docs.marklogic.com/5.0doc/docapp.xqy#display.xqy?fname=http://pubs/5.0doc/xml/search-dev-guide/search-api.xml%2343671 has more on this option. http://docs.marklogic.com/5.0doc/docapp.xqy#display.xqy?fname=http://pubs/5.0doc/xml/search-dev-guide/search-api.xml%2343671有更多关于这个选项。

Or you could call cts:search directly. 或者你可以直接拨打cts:search The searchable expression is the first argument. 可搜索的表达式是第一个参数。

declare namespace ns1="http://test/namespace/1" ;
declare variable $query as cts:query external ;
cts:search(/ns1:doc, $query)

There might be other options, too. 也可能有其他选择。 For example, you could set up multiple fields and search using field queries. 例如,您可以设置多个字段并使用字段查询进行搜索。

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

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