Thanks Michael, I was getting element-query and element-word-query mixed up.
-----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Michael Sokolov Sent: Saturday, February 27, 2010 1:32 PM To: 'General Mark Logic Developer Discussion' Subject: RE: [MarkLogic Dev General] Element specific search withlikenamedtext nodes Sorry to be contradictory, but that isn't what I've seen, and it's definitely contrary to the documentation. What's going on in Runstein's query is that all <name>s in <a> at any level are searched because element-query searches all descendants, but element-word-query only searches immediate text node descendants. There are a few other things to try that might produce indexed queries with the same results, but there isn't any cts:query equivalent to the xpath. For example you could add a cts:field that includes <a> and excludes <b>, and search that. That would work with the examples given, but only because there are no other nodes around. In my experience we generally end up needing to do at least some data manipulation in order to get most queries to be fully indexed. -Mike > -----Original Message----- > From: [email protected] > [mailto:[email protected]] On Behalf Of > Lee, David > Sent: Thursday, February 25, 2010 3:49 PM > To: General Mark Logic Developer Discussion > Subject: RE: [MarkLogic Dev General] Element specific search > with likenamedtext nodes > > I've found by practice (not sure if its documented) that > element-word-query matches all decendant text nodes not just direct > descendants. Very annoying for just this use case (but very > useful for > other use cases). > Would love an option like for directory() where you can > specify to decend or not ... > > > > -----Original Message----- > From: [email protected] > [mailto:[email protected]] On Behalf Of > Runstein, Robert E. (Contr) (IS) > Sent: Thursday, February 25, 2010 3:30 PM > To: General Mark Logic Developer Discussion > Subject: [MarkLogic Dev General] Element specific search with > like namedtext nodes > > Hi All, > > Given the following two documents: > <doc> > <a> > <name>Bob</name> > <b> > <name>Jim</name> > </b> > </a> > </doc> > > <doc> > <a> > <name>Jim</name> > <b> > <name>Bob</name> > </b> > </a> > </doc>> > > The following returns just the first document: > fn:doc()[./doc/a/name = "Bob"] > > I'd like to be able to get the same result using cts:query. > Specifying the exact elements to search using the > cts:element-query and cts:element-word-query as below, > matches both documents when I would like only the first to match. > > let $q := > <q><cts:element-query> > <cts:element>doc</cts:element> > <cts:element-query> > <cts:element>a</cts:element> > <cts:element-word-query> > <cts:element>name</cts:element> > <cts:text xml:lang="en">Bob</cts:text> > </cts:element-word-query> > </cts:element-query> > </cts:element-query></q> > > return search:resolve($q/element()) > > ==> > > <search:response total="2" start="1" page-length="10" > xmlns:search="http://marklogic.com/appservices/search"> > <search:result index="1" uri="/bobtest" path="fn:doc("/bobtest")" > score="56" confidence="0.491559" fitness="0.651473"> > <search:snippet> <search:match path="fn:doc("/bobtest")/doc/a/name"> > <search:highlight>Bob</search:highlight> > </search:match> > </search:snippet> > </search:result> > <search:result index="2" uri="/bobtest2" path="fn:doc("/bobtest2")" > score="56" confidence="0.491559" fitness="0.651473"> > <search:snippet> <search:match > path="fn:doc("/bobtest2")/doc/a/b/name"> > <search:highlight>Bob</search:highlight> > </search:match> > </search:snippet> > </search:result> > <search:metrics> > > <search:query-resolution-time>PT0.094S</search:query-resolution-time> > <search:facet-resolution-time>PT0S</search:facet-resolution-time> > > <search:snippet-resolution-time>PT0S</search:snippet-resolution-time> > <search:total-time>PT0.094S</search:total-time> > </search:metrics> > </search:response> > > The API docs for cts:element-word-query state: > "Returns a query matching elements by name with text content > containing a given phrase. Searches only through immediate > text node children of the specified element as well as any > text node children of child elements defined in the Admin > Interface as element-word-query-throughs or phrase-throughs; > does not search through any other children of the specified element." > > No query or phrase throughs have been configured. Is my > query incorrect for what I'm trying to accomplish? Thanks. > > Bob > _______________________________________________ > General mailing list > [email protected] > http://xqzone.com/mailman/listinfo/general > _______________________________________________ > General mailing list > [email protected] > http://xqzone.com/mailman/listinfo/general > _______________________________________________ General mailing list [email protected] http://xqzone.com/mailman/listinfo/general _______________________________________________ General mailing list [email protected] http://xqzone.com/mailman/listinfo/general
