Hi Dave, That works for me on 7.0-3. Are you sure document looks exactly like that? Here is what I did:
xdmp:document-insert("/Dave.xml", <lncr:doc xmlns:lncr="http://www.lexis-nexis.com/lncr"> <lncr:metadata> <lncr:titles> <lncr:title>People v. Johnson</lncr:title> </lncr:titles> </lncr:metadata> </lncr:doc>); cts:search(doc("/Dave.xml"), 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") ) ) That returns the document. What version of MarkLogic? -Danny From: general-boun...@developer.marklogic.com [mailto:general-boun...@developer.marklogic.com] On Behalf Of Steiner, David J. (LNG-DAY) Sent: Tuesday, September 09, 2014 7:52 AM To: General Mark Logic Developer Discussion (general@developer.marklogic.com) Subject: [MarkLogic Dev General] cts:element-query 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 General@developer.marklogic.com http://developer.marklogic.com/mailman/listinfo/general