限制 cts:search 以设置 xml 个元素的数量
Restrict cts:search to set number of xml elements
我有一个 cts:query
,我想限制我的 cts:query
只搜索一些 xml 元素。这是否可以在不创建任何字段索引或修改我的 cts:query
的情况下实现,因为我的 cts:query
非常大......当我这样做时
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:query
,如下例所示。我得到的表达式是无法搜索的..如何实现这个?..只是为了完成我的代码,下面是我的 cts:query
,下面只是一个示例,它更大 cts:query
:)
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"))
要回答您的核心问题,您可以使用 cts:element-query 将查询限制为特定元素。
您的查询有很大的优化空间。我不认为它会针对大型数据集进行扩展。我强烈建议您拥有任何您接触过的 MarkLogic 资源,看看您正在尝试做什么并评估您的方法。
我有一个 cts:query
,我想限制我的 cts:query
只搜索一些 xml 元素。这是否可以在不创建任何字段索引或修改我的 cts:query
的情况下实现,因为我的 cts:query
非常大......当我这样做时
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:query
,如下例所示。我得到的表达式是无法搜索的..如何实现这个?..只是为了完成我的代码,下面是我的 cts:query
,下面只是一个示例,它更大 cts:query
:)
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"))
要回答您的核心问题,您可以使用 cts:element-query 将查询限制为特定元素。
您的查询有很大的优化空间。我不认为它会针对大型数据集进行扩展。我强烈建议您拥有任何您接触过的 MarkLogic 资源,看看您正在尝试做什么并评估您的方法。