Since you mention xdmp:plan, is it safe to assume 4.2-1? I don't think you're missing anything, but it looks like the fn:not() predicate isn't searchable in 4.2-1. Here's what I see without and with the not(). As you can see, the skos:broader term doesn't appear as a constraint in the with-not query. If that use-case is important to you, I'd suggest contacting support to file a bug or an RFE, whichever turns out to be appropriate.
declare namespace skos="http://www.w3.org/2004/02/skos/core#"; xdmp:plan( //skos:Concept[skos:broader]) => <qry:query-plan xmlns:qry="http://marklogic.com/cts/query"> <qry:info-trace>xdmp:eval("declare namespace skos=&quot;http://www.w3.org/2004/02/skos/core...", (), <options xmlns="xdmp:eval"><root>/Users/mblakele/Source/marklogic/cq</root><isolation>diffe...</options>)</qry:info-trace> <qry:info-trace>Analyzing path: fn:collection()/descendant::skos:Concept[skos:broader]</qry:info-trace> <qry:info-trace>Step 1 is searchable: fn:collection()</qry:info-trace> <qry:info-trace>Step 2 is searchable: descendant::skos:Concept[skos:broader]</qry:info-trace> <qry:info-trace>Path is fully searchable.</qry:info-trace> <qry:info-trace>Gathering constraints.</qry:info-trace> <qry:info-trace>Step 2 predicate 1 contributed 1 constraint: skos:broader</qry:info-trace> <qry:partial-plan> <qry:or-two-queries> <qry:term-query weight="0"> <qry:key>45164952917553413</qry:key> </qry:term-query> <qry:term-query weight="0"> <qry:key>7137106099583973772</qry:key> </qry:term-query> </qry:or-two-queries> </qry:partial-plan> <qry:info-trace>Step 2 predicate 1 contributed 1 constraint: skos:broader</qry:info-trace> <qry:partial-plan> <qry:or-two-queries> <qry:term-query weight="0"> <qry:key>45164952917553413</qry:key> </qry:term-query> <qry:term-query weight="0"> <qry:key>7137106099583973772</qry:key> </qry:term-query> </qry:or-two-queries> </qry:partial-plan> <qry:info-trace>Executing search.</qry:info-trace> <qry:final-plan> <qry:and-query> <qry:term-query weight="0"> <qry:key>15877381803780460115</qry:key> </qry:term-query> <qry:or-two-queries> <qry:term-query weight="0"> <qry:key>45164952917553413</qry:key> </qry:term-query> <qry:term-query weight="0"> <qry:key>7137106099583973772</qry:key> </qry:term-query> </qry:or-two-queries> <qry:or-two-queries> <qry:term-query weight="0"> <qry:key>45164952917553413</qry:key> </qry:term-query> <qry:term-query weight="0"> <qry:key>7137106099583973772</qry:key> </qry:term-query> </qry:or-two-queries> </qry:and-query> </qry:final-plan> <qry:info-trace>Selected 0 fragments</qry:info-trace> <qry:result estimate="0"/> </qry:query-plan> And with not(): declare namespace skos="http://www.w3.org/2004/02/skos/core#"; xdmp:plan( //skos:Concept[not(≤skos:broader)]) => <qry:query-plan xmlns:qry="http://marklogic.com/cts/query"> <qry:info-trace>xdmp:eval("declare namespace skos=&quot;http://www.w3.org/2004/02/skos/core...", (), <options xmlns="xdmp:eval"><root>/Users/mblakele/Source/marklogic/cq</root><isolation>diffe...</options>)</qry:info-trace> <qry:info-trace>Analyzing path: fn:collection()/descendant::skos:Concept[fn:not(skos:broader)]</qry:info-trace> <qry:info-trace>Step 1 is searchable: fn:collection()</qry:info-trace> <qry:info-trace>Step 2 is searchable: descendant::skos:Concept[fn:not(skos:broader)]</qry:info-trace> <qry:info-trace>Path is fully searchable.</qry:info-trace> <qry:info-trace>Gathering constraints.</qry:info-trace> <qry:info-trace>Executing search.</qry:info-trace> <qry:final-plan> <qry:and-query> <qry:term-query weight="0"> <qry:key>15877381803780460115</qry:key> </qry:term-query> </qry:and-query> </qry:final-plan> <qry:info-trace>Selected 0 fragments</qry:info-trace> <qry:result estimate="0"/> </qry:query-plan> -- Mike On 3 Dec 2010, at 11:09 , Darin McBeath wrote: > So, I want to count the number of skos:Concept records that have a > skos:broader > child. > > I have fragmented on skos:Concept (there are 352950 skos:Concept fragments in > the DB). > > The following query works as expected: > > declare namespace skos="http://www.w3.org/2004/02/skos/core#"; > > xdmp:estimate(//skos:Concept[skos:broader]) > > This returns 352944 (which is correct) > > However, > > xdmp:estimate(//skos:Concept[not(skos:broader)]) > > returns 352950 (every skos:Concept fragment in the DB instead of the expected > value of 6). > > > So, I then moved on to search. > > xdmp:estimate(cts:search(//skos:Concept, > > cts:not-query(cts:element-query((QName("http://www.w3.org/2004/02/skos/core#","broader")), > > > cts:and-query(()))))) > > returns a value of 6. > > and > > xdmp:estimate(cts:search(//skos:Concept, > > cts:element-query((QName("http://www.w3.org/2004/02/skos/core#","broader")), > cts:and-query(())))) > > returns a value of 352944. > > > So, since MarkLogic indexes parent-child relationships, why wouldn't the > first > simple query ... just using xpath expressions ... return the correct result. > > Thanks. > > Darin. > > p.s. No, I didn't bother to do a trace or xdmp:plan ;-) The xpath example > appears so simple (on the surface) I'm a bit stumped as to why this would not > correctly return an unfiltered result. > _______________________________________________ > General mailing list > [email protected] > http://developer.marklogic.com/mailman/listinfo/general > _______________________________________________ General mailing list [email protected] http://developer.marklogic.com/mailman/listinfo/general
