我要求我们只需要在其活动版本中具有<associated-bundles>元素的文档中执行marklogic搜索。
以下是我们的文档结构
<document document-status='active'> <file> <version id=1 version-status='active'> <file-name/> <associated-bundles> <bundle doc-id="100082"></bundle> <bundle doc-id="100083"></bundle> <bundle doc-id="100000"></bundle> </associated-bundles> ... <file-level-visits>3</file-level-visits> </version> <version id=2 version-status='archived'> <file-name/> <uploaded-by> ... <file-level-visits>2</file-level-visits> </version> <version id=3 version-status='archived'> <file-name/> <uploaded-by> ... <file-level-visits>4</file-level-visits> </version> </file>考虑到上面的文档结构,我只需要在活动版本中具有<associated-bundles>元素的文档上进行搜索。
注意:文档中只有一个活动版本。
以下是仅在活动文件“version-status”内搜索的查询。 但除此之外,我还希望为文档添加“ifExists”检查<associated-bundles> 。
cts:element-query (xs:QName ("version"),cts:and-query ((cts:element-attribute-value-query(fn:QName("","version"), fn:QName("","version-status"), "active", ("lang=en"), 1) )));请让我知道,如何实现这一目标。
I have a requirement that we need to perform marklogic search only within the documents which have <associated-bundles> element in it's active version.
Below is our document structure
<document document-status='active'> <file> <version id=1 version-status='active'> <file-name/> <associated-bundles> <bundle doc-id="100082"></bundle> <bundle doc-id="100083"></bundle> <bundle doc-id="100000"></bundle> </associated-bundles> ... <file-level-visits>3</file-level-visits> </version> <version id=2 version-status='archived'> <file-name/> <uploaded-by> ... <file-level-visits>2</file-level-visits> </version> <version id=3 version-status='archived'> <file-name/> <uploaded-by> ... <file-level-visits>4</file-level-visits> </version> </file>Considering above document structure, I need to perform search only on the documents which have <associated-bundles> element in their active version.
Note: There is only 1 active version in the document.
Below is the query to search only within active file "version-status". But in addition to this, I want to include 'ifExists' check of <associated-bundles> for the document.
cts:element-query (xs:QName ("version"),cts:and-query ((cts:element-attribute-value-query(fn:QName("","version"), fn:QName("","version-status"), "active", ("lang=en"), 1) )));Please let me know, how to achieve this.
最满意答案
您可以使用cts:element-query()使用文档中的以下语法检查元素是否存在:
cts:element-query(xs:QName("my-element"),cts:and-query( () ))You can check for the existence of an element using cts:element-query() using the syntax below from the documentation:
cts:element-query(xs:QName("my-element"),cts:and-query( () ))更多推荐
发布评论