2
votes

I'm presently using eXist-db 2.2 on Windows 7, with 1.3gb of RAM allocated for Java.

I've been trying to optimize an XQuery:

xquery version "3.0";

let $phrase := "flight"
let $nbsp := " "
    let $containing := collection("/db/MyDb")//value[contains(.,$phrase)]
    return (count($containing))

but this query always performs a scan on the database. My collection.xconf is as such:

<collection xmlns="http://exist-db.org/collection-config/1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <index>
        <fulltext default="none" attributes="false"/>
        <!-- create qname="value" content="mixed" /-->
        <lucene>
            <analyzer class="org.apache.lucene.analysis.standard.StandardAnalyzer"/>
            <analyzer id="ws" class="org.apache.lucene.analysis.WhitespaceAnalyzer"/>
            <text qname="value" analyzer="ws"/>
        </lucene>
        <range>
            <create qname="value">
                <field name="value" match="value" type="xs:string" case="no"/>
            </create>
        </range>
    </index>
</collection>

The value node exist in multiple levels of the XML, so I was hoping that it will index this particular node regardless of where it's at in the tree.

Do you have any suggestions on how I can use the index?

Updated to include an XML fragment I'm using:

<v1 attribute1="b3492">
    <person>
        <sub id="b733" name="b733" />
        <section id="5897" label="a">
            <section id="e70e" label="a.a" >
                <field id="7e8a" label="a.a.f01">
                    <value type="String">test value</value>
                </field>
                <section id="78ea1" label="a.a.s01" >
                    <field id="7e8a" label="a.a.s01.f01">
                        <value type="String">test value 2</value>
                    </field>
                </section>
            </section>
        </section>
    </person>
</v1>

The size of the XML files I am using ranges from <10K to >2M. I have loaded about 12,000 of these files and a basic query takes upwards of 5 minutes at the moment.

An update --> I have updated the collection.xconf as following:

<collection xmlns="http://exist-db.org/collection-config/1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <index>
        <fulltext default="none" attributes="false"/>
        <!-- create qname="value" content="mixed" /-->
        <lucene>
            <analyzer class="org.apache.lucene.analysis.standard.StandardAnalyzer"/>
            <analyzer id="ws" class="org.apache.lucene.analysis.WhitespaceAnalyzer"/>
            <text qname="value" analyzer="ws"/>
        </lucene>
        <range>
            <create qname="value" type="xs:string"/>
        </range>
    </index>
</collection>

The index now appears to be used, as the queries are returning results faster.. However "faster" here means that results are returned after about 1 minute, which is still too slow. Are there additional directives to improve index utilization?

1
For query/indexing question, please always attach an example XML fragment that is queried. - DiZzZz

1 Answers

0
votes

Your index definition doesn't appear to match the documentation.

I think you should use

<range>
  <create qname="value" type="xs:string" />
</range>

Your current index is probably looking for value/value.