|
From: Grégoire C. <gco...@gm...> - 2010-02-26 21:36:33
|
Hi,
I have a XML file which contains 35,000 towns like this :
<towns>
<town>
<name>Townville upon River</name>
<zipcode>12345</zipcode>
<alt_names>
<name>townville-upon-river</name>
<name>townville</name>
</alt_names>
</town>
...
</towns>
The use-case is a "Google Suggest" functionality. That is, when a user
adds a caracter in the XForm, a request is sent to the server, where the
string ($place) is converted lowercase and spaces are all replaced by
hyphens, so that it can be compared with the alternate names found in
alt_names/name. The XQuery is :
for $town in
collection("/db/towns")//town[starts-with(alt_names/name,$place)]
order by $town/name ascending
return
<town>
{$town/name}
{$town/zipcode}
</town>
Unfortunately, the performance was poor by default (600 ms by request),
so I tried to add a "collection.xconf" which contains :
<collection xmlns="http://exist-db.org/collection-config/1.0">
<index>
<fulltext default="none" attributes="false">
</fulltext>
<lucene>
<text qname="name" type="xs:string"/>
<text qname="zipcode" type="xs:integer"/>
</lucene>
<ngram qname="alt_names/name"/>
</index>
</collection>
Now the performance is... even worse, at around 1 second per request.
What should I add to my "xconf" file to improve the performance?
Best regards,
Gregoire
|