Must be doing something wrong because it feels like I'm following the
documentation nearly exactly.
Data:
<lncr:doc xmlns:lncr="http://www.lexis-nexis.com/lncr">
<lncr:metadata>
<lncr:titles>
<lncr:title>People v. Johnson</lncr:title>
</lncr:titles>
...
</lncr:doc>
This works:
cts:search(fn:doc(),
cts:element-word-query(fn:QName("http://www.lexis-nexis.com/lncr","title"),
"people")
)[1]
This doesn't:
cts:search(fn:doc(),
cts:element-query(fn:QName("http://www.lexis-nexis.com/lncr","titles"),
cts:element-word-query(fn:QName("http://www.lexis-nexis.com/lncr","title"),
"people")
)
)[1]
But it seems like it should...
>From the documentation:
The cts:element-query<http://docs.marklogic.com/cts:element-query> function
searches through a specified element and all of its children. It is used to
narrow the field of search to the specified element hierarchy, exploiting the
XML structure in the data. Also, it is composable with other
cts:element-query<http://docs.marklogic.com/cts:element-query> functions,
allowing you to specify complex hierarchical conditions in the
cts:query<http://docs.marklogic.com/cts:query> expressions.
For example, the following search against a Shakespeare database returns the
title of any play that has SCENE elements that have SPEECH elements containing
both the words 'room' and 'castle':
for $x in cts:search(fn:doc(),
cts:element-query(xs:QName("SCENE"),
cts:element-query(xs:QName("SPEECH"),
cts:and-query(("room", "castle")) ) ) )
return
($x//TITLE)[1]
This query returns the first TITLE element of the play. The TITLE element is
used for both play and scene titles, and the first one in a play is the title
of the play.
In fact, this doesn't work, but it seems like it should if in fact, "the
cts:element-query function searches through a specified element and all of its
children" as the documentation says.
cts:search(fn:doc(),
cts:element-query(fn:QName("http://www.lexis-nexis.com/lncr","titles"),
"people")
)[1]
I'm trying to build a query where I do different word searches at different
paths within the documents
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general