条件组合索引:当有几种小数类型的索引时,查询不到想要的结果

Conditional combined indexes:When there are several decimal types of indexes, the desired results can not be queried

使用版本:4.5.0

db/system/config/db/test/collection.xconf代码如下:

<range>
        <create qname="item">
            <condition attribute="name" value="number"/>
            <field name="number" match="@value" type="xs:decimal"/>
        </create>
        <create qname="item">
            <condition attribute="name" value="acreage"/>
            <field name="acreage" match="@value" type="xs:decimal"/>
        </create>
        <create qname="item">
            <condition attribute="name" value="radii"/>
            <field name="radii" match="@value" type="xs:decimal"/>
        </create>
        <create qname="item">
            <condition attribute="name" value="diameter"/>
            <field name="diameter" match="@value" type="xs:decimal"/>
        </create>
    </range>

Browse Indexes

db/test一个XML文件的代码如下:

<root>
<item name="number" value="4"/>
<item name="acreage" value="5"/>
<item name="radii" value="6"/>
<item name="diameter" value="7"/> </root>

查询语句:

//item[@name='radii'][@value>5.0]

Query Profiling

无结果

理论上可以找到XML文件,结果找不到是什么原因?你能帮助我吗?谢谢!

根据您在此处尝试使用的 eXist 条件组合索引功能的文档,在我看来,该功能仅支持字符串比较(具有可选的 "numeric" 模式)。参见 https://exist-db.org/exist/apps/doc/newrangeindex#D3.21.18。换句话说,您的 @type="xs:decimal" 不会导致您的属性值被转换为 xs:decimal;实际上,它们被索引为 xs:string.

因此,为了使您的查询能够处理给定的数据,请将谓词更改为 [@value gt "5"]

或者,要强制进行数字比较,请将 numeric="yes" 添加到索引定义中的 <field> 元素,然后将谓词更改为 [@value gt "5.0"].