Hi Rob,
Here are a few ideas.
1) If you can get away with not starting the lexicon lookup with a
wildcard character, it will probably help a lot. For example,
concat($q, "*") for your match string instead.
2) Those other index options you mentioned will help with cts:query
resolution, but not with the lexicon query. They can help the lexicon
query (especially the three-character searches, which is a 3-char
wildcard index) if you constrained your cts:element-value-match with a
cts:query. That might be another idea to speed this up, if you decide
you really need the leading wildcard. Then your query could look
something like:
cts:element-value-match(xs:QName("Author"), concat("*", $q, "*"),
("ascending", "case-insensitive"),
cts:element-word-query(xs:QName("Author"), concat("*", $q, "*"),
"wildcarded") )
3) Another thing to think about is to use a collation for the range
index that is case-insensitive, or has some other options like
diacritic-insensitive (if that makes sense for your application). That
can lower the number of entries in the index (there would be one entry
instead of two for "E. B. White" and "E. B. WHITE", for example).
-Danny
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Whitby,
Rob, CMG
Sent: Monday, August 04, 2008 3:01 AM
To: [email protected]
Subject: [MarkLogic Dev General] Indexes and query tuning
Hi all,
I'm trying to implement an auto-complete dropdown which searches a range
index with approx 3 million values. The plan is to run a search after
the user has typed at least 3 characters, and match that string anywhere
in the values. The query I'm using is:
(: example search for authors with whi anywhere in their name :)
let $q := 'whi'
return cts:element-value-match(xs:QName("Author"), concat("*", $q, "*"),
("ascending", "case-insensitive"))
This currently takes 10 seconds.
I'm hoping that adding some extra indexes will help the performance.
Currently I have the following enabled:
- Word searches
- Fast phrase searches
- Fast element word searches
- Fast element trailing wildcard searches
- Three character searches
I'm struggling to work out the practical uses of the different indexes -
they all sound the same and the documentation just causes more confusion
:(
Can anyone explain what indexes would improve my query, or is there a
better way of writing the query itself?
Thanks a lot,
Rob
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general