Dear Truong,
in your scenario, the contains text expression is not much faster than the fn:contains() function because the returned result set is very large. As an example, please compare the following two queries:
//*:specification[contains(text(), 'Variable4')] //*:specification[text() contains text 'variable4']
In other words: accessing the index and checking the nodes' parents takes pretty much the same time as sequentially scanning all texts of the <specification/> elements. Next, please note that, in many cases, "contains text" and "contains()" are not equivalent and will return different results (but you may be aware of this anyway).
In the last query you discussed, I assume that the query optimizer cannot benefit from the full text index due to the OR operator. As an alternative, you can directly access the index as follows:
db:fulltext('truong', 'Specification')/parent::*:specification
Hope this helps, Christian ___________________________
On Sun, Nov 27, 2011 at 10:30 PM, Dimitar Popov Dimitar.Popov@uni-konstanz.de wrote:
Am Sonntag, 27. November 2011, 21:57:41 schrieb Truong An Nguyen:
Hi Dimitar,
handler/specification is a node text, not an attribute. That is the reason that I used fulltext search just for $hd/specification.
I don't understand why full text index is not used here.
I'm not sure if it is possible to re-write the query using index access, because of the nested for-loop and the "or" conditions. Someone more knowledgeable with the compiler optimizations than me could probably give you more details.
Greetings, Dimitar _______________________________________________ BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk