Let me try to answer the general question... The thing to remember about cts:search is it's a controlled vocabulary. You can only express constraints using cts:query constructs, and those constructs were designed and defined by our engineering team with our indexes in mind.
XPath was designed and defined by a W3C committee years before MarkLogic was founded. Our engineering team has built innovative indexes that do great things evaluating XPath, but every XPath evaluation has to be behave according to the W3C spec even if the behavior doesn't lend itself well to optimization. A good example is negation, which Christopher mentioned during the MLUC11 panel. An XPath fn:not() has to be accurate, which makes it non-optimized because there's no reliable indexes for things that don't exist. A cts:not-query() on the other hand behaves according to our definition, which is that it strictly removes from the result all documents the indexes see as matching the negated query. What's the difference? Well, if there's a document that the indexes see as a candidate match for the negated query but isn't actually a real match, with XPath we have to still include the document in the result meaning we can't use indexes to help, but with cts:not-query() our definition of behavior allows us to exclude the document using indexes. I wouldn't go so far as to say that cts:search is always as fast or faster than XPath. I've seen cases where it's the opposite. We work very hard to optimize XPath. And of course you can use cts:query constructs in XPath with cts:contains() so the line between the two tends to blur. -jh- On May 12, 2011, at 8:17 AM, seme...@hotmail.com wrote: > I mean in general. I've always heard that cts:search is almost always as fast > or faster than XPath. I'm finding that to be the case, and wondering why that > is the case in general. > > From: breinhol...@ldschurch.org > To: general@developer.marklogic.com > Date: Thu, 12 May 2011 09:11:17 -0600 > Subject: Re: [MarkLogic Dev General] Why is cts:search so much faster than > XPath? > > Perhaps you could give us the XPath and the cts:search() code. It would make > it easier to diagnose. > > - Keith > > From: general-boun...@developer.marklogic.com > [mailto:general-boun...@developer.marklogic.com] On Behalf Of > seme...@hotmail.com > Sent: Thursday, May 12, 2011 9:05 AM > To: general@developer.marklogic.com > Subject: [MarkLogic Dev General] Why is cts:search so much faster than XPath? > > I wrote awhile ago that I thought it was usually best to use search:search > for full text searching, cts:search for node selection out of the db, and > XPath for node selection within a document. I just ran into a situation that > doing the same query for nodes in the DB using cts:search was 6 times faster > than using XPath. > > So what is it about cts:search that makes it so fast? I assume that there are > optimizations under the covers, but how is cts:search able to gain from the > optimizations but XPath is not? Just curious. > > -Ryan > > > NOTICE: This email message is for the sole use of the intended recipient(s) > and may contain confidential and privileged information. Any unauthorized > review, use, disclosure or distribution is prohibited. If you are not the > intended recipient, please contact the sender by reply email and destroy all > copies of the original message. > > > _______________________________________________ General mailing list > General@developer.marklogic.comhttp://developer.marklogic.com/mailman/listinfo/general > _______________________________________________ > General mailing list > General@developer.marklogic.com > http://developer.marklogic.com/mailman/listinfo/general
_______________________________________________ General mailing list General@developer.marklogic.com http://developer.marklogic.com/mailman/listinfo/general