Upayavira wrote:
I've used code (see other thread - subject "To create indexes (warning: Xindice only)") to create an index. But it doesn't appear to have made a difference to the speed of my app.
If I need to query a colleciton of 70 documents, all of the following format:
<doc>
<title>Some title</title>
</doc>
with an xpath of /doc[contains(title, 'Some')]
I _think_ that contains() queries can not use indexes (but I can be mistaken). See also IndexedSearchTest.java, it has tests for starts-with() search, but not for contains().
How would I create an index that would speed that up?
Implement ValueTextIndexer using Lucene (and treat contains() query more like "contains all of the words" query?) ;-P
You see, xindice index is a btree index built on values of elements (or names of elements - for name type index). To traverse such index, you start from the top of the tree and look in what branch first letter would be (I'm simplifying a bit)... But contains() query does not provide you with first letter!
Do I just provide 'title' as the field to be indexed? Or can I specify /doc/title? How does it know which nodes to index?
For queries on exact content match or on starts-with, you should build index of type "ValueIndexer", with index pattern "title". It will index contents of all <title/> elements in your data. Step through testSpecificElementNoAttributeValueIndexedStartsWithSearch to see how it works.
Vadim