Database Reference
In-Depth Information
To define indexes for a specific collection (and its subcollections), you need to do the
following:
1. The database has a system collection /db/system/config . Under here, you create a
collection path that reflects the path from the database root ( /db ) to the collec‐
tion that holds the data you wish to index. For instance, if you wanted to create
indexes for /db/myapp/data , you would create the collection /db/system/
config/db/myapp/data .
2. Create an XML file there called collection.xconf with the following basic contents:
<collection xmlns= "http://exist-db.org/collection-config/1.0" >
<index>
<!-- Index definitions here -->
</index>
</collection>
All elements in the collection.xconf file must be in the http://exist-db.org/
collection-config/1.0 namespace.
3. Add the index definitions as children of the index element (details covered
shortly, and for full text in Chapter 12 ).
4. If there's already data in the collection, don't forget to reindex! See “Maintaining
Indexes” on page 278 for details.
Configuring Range Indexes
You may define range indexes by adding create elements to the index configuration
in collection.xconf . For instance:
<collection xmlns= "http://exist-db.org/collection-config/1.0" >
<index xmlns:ns1= "http://mynamespace" >
<create qname= "ns1:article" type= "xs:string" />
<create qname= "@price" type= "xs:double" />
</index>
</collection>
This creates a string-type range index on every article element (in the http://myna
mespace namespace) and a double-precision floating-point range index on every
price attribute, for every document in the collection (and subcollections).
The create element must be a direct child of the index element. It takes the form:
<create qname = xs: QName
type = xs:QName />
where:
Search WWH ::




Custom Search