I am updating an XML file in an exist-db collection and I have to check if and id is present to decide if I have to replace or insert something in my document.
I noticed that as the file grows the query execution time worsens significantly and I decided to add an index for my file.
I understand that I have to do that in the conf.xml of my exist-db as it is shown in this example:
<!-- Range indexes -->
<create qname="title" type="xs:string"/>
<create qname="author" type="xs:string"/>
<create qname="year" type="xs:integer"/>
<!-- "old" context-dependant configuration using the path attribute: -->
<create path="//booktitle" type="xs:string"/>
I want to add an index for the attribute id in an xml like the following:
<server>
<formal>
<lastimage>
<harvested>
<coverages>
<coverage active="true" id="EUDEM">
...
</coverage>
</coverages>
</harvested>
</lastimage>
</formal>
</server>
I don't think that adding
<create qname="id" type="xs:string"/>
is enough.
What is the right way of adding and index in exist-db for this attribute?
You're close! Just add @ to the beginning of the qname attribute:
The relevant section of the documentation is Configuration by path vs. configuration by qname: