我想对 xml 标签进行分面,并对标签值进行子分面,我有一个如下所示的 xml 文档
<TermiteJServiceResponse>
<EntityTypeHit type="DRUG">
<HitCollection>
<Hit type="DRUG" id="CHEMBL1201288">
<Name>Dantrolene</Name>
</Hit>
<Hit type="DRUG" id="CHEMBL286398">
<Name>Propylene Glycol</Name>
</Hit>
<Hit type="DRUG" id="GXC376D7F8C0E7A0C3787E8A2384DC56E80">
<Name>PEG400</Name>
</Hit>
</HitCollection>
</EntityTypeHit>
<EntityTypeHit type="COMPOUNDS">
<HitCollection>
<Hit type="COMPOUNDS" id="A-409912.5">
<Name>A-409912.5</Name>
</Hit>
<Hit type="COMPOUNDS" id="A-409912">
<Name>A-409912</Name>
</Hit>
</HitCollection>
</EntityTypeHit>
<EntityTypeHit type="GENE">
<HitCollection>
<Hit type="GENE" id="TRH">
<Name>thyrotropin-releasing hormone</Name>
</Hit>
</HitCollection>
</EntityTypeHit>
<EntityTypeHit type="BIOPROC">
<HitCollection>
<Hit type="BIOPROC" id="BP70302">
<Name>infusion</Name>
</Hit>
<Hit type="BIOPROC" id="D009200">
<Name>Myocardial Contraction</Name>
</Hit>
<Hit type="BIOPROC" id="BP70198">
<Name>cmax values</Name>
</Hit>
<Hit type="BIOPROC" id="D001835">
<Name>Body Weight</Name>
</Hit>
<Hit type="BIOPROC" id="D062186">
<Name>Arterial Pressure</Name>
</Hit>
<Hit type="BIOPROC" id="BP70209">
<Name>contractility</Name>
</Hit>
<Hit type="BIOPROC" id="D006339">
<Name>Heart Rate</Name>
</Hit>
<Hit type="BIOPROC" id="BP70316">
<Name>intravenal</Name>
</Hit>
</HitCollection>
</EntityTypeHit>
<EntityTypeHit type="SPECIES">
<HitCollection>
<Hit type="SPECIES" id="D051381">
<Name>Rats</Name>
</Hit>
</HitCollection>
</EntityTypeHit>
</TermiteJServiceResponse>
我想基于上述文档 DRUGS 中的方面和药物名称的子方面以及类似的化合物和化合物名称的子方面
最佳答案
查看“Constrained Searches and Faceted Navigation”上的 MarkLogic 搜索开发人员指南。
使用搜索 API,您可以使用 <search:options>
定义约束和构面(一种约束类型)。元素。对于每个方面,您需要定义一个范围索引。理想情况下,您可以使用语义命名的元素( <DRUG>
而不是 <Hit type="DRUG">
)来简化索引;但是,如果此模式不灵活,那么您可以 define a path range index超过//Hit[type="DRUG"]
,并在您的搜索选项中引用它,例如:
<constraint name="Drug">
<range type="xs:string" facet="true">
<path-index>
//Hit[type="DRUG"]
</path-index>
</range>
</constraint>
当您使用 search:search
调用搜索 API 时或search:resolve
,它将返回 search:response
包含您在 <search:options>
中定义的结果(片段)和约束或构面值的元素.
关于marklogic - XML 标签值的分面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36136303/