On Mon, 10 Aug 2009 08:27:03 -0700, Glidden, Douglass A
<[email protected]> wrote:
Geert,
I've seen you mention this a couple of times, and I got a little curious
this time. I ran a little test, with the finding that
cts:search(doc()//para, ...)
and
cts:search(doc(), ...)//para
Talk of fragment roots is a bit of a red herring. The point is that the
two
expressions are asking different questions and that is why you are seeing
different results.
cts:search( doc()//para, $q ) means "find me all the para elements that
match
the given query"
cts:search( doc(), $q )//para means "find me all the documents that match
the
given query, and then find all the para elements in those"
This is just following the general path expression rules, as you can see by
rewriting the second expression:
let $docs := cts:search( doc(), $q )
return $docs//para
The general rules for // say to get the set of nodes from the left of the
path
operator -- here $docs, which is cts:search( doc(), $q ) -- and then
evaluate
the right side of the operator in the context of that set of nodes.
Looking at the other expression, the doc()//para as the first argument to
cts:search means evalate doc() (everything document in the database) and
then
evaluate //para in the context of that set (all the para elements in the
database).
We'll actually evaluate this with indices for efficiency, but that's the
semantics
of the expression. Then, in the context of this set of para elements,
evaluate
the query, returning only those para elements that match it.
//Mary
are not equivalent. The first search will return only those para
elements for which the cts:query is true (whether this is done using
indexes if possible or always through filtering I'm not sure); the
second will return all para elements within any document for which the
search terms are true. Would you please clarify what you mean by this?
You obviously have a much deeper understanding of Mark Logic than I do,
so I want to understand what you are trying to say.
The test I ran uses a simple document that looks like this:
<doc>
<para>
<foo>1</foo>
</para>
<para>
<foo>2</foo>
</para>
</doc>
Then I executed the following two searches:
1.
cts:search(fn:doc()//para,
cts:element-value-query(xs:QName("foo"), "1") )
2.
cts:search(fn:doc(), cts:element-value-query(xs:QName("foo"),
"1") )//para
with the following results:
1.
<para>
<foo>1</foo>
</para>
2.
<para>
<foo>1</foo>
</para>
<para>
<foo>2</foo>
</para>
Of course, I didn't define any fragment roots, so the whole document is
a single fragment.
Doug Glidden
Software Engineer
The Boeing Company
[email protected]
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general