Hi Neil, Did you enable word positions in your database? If not, that means distance is only considered in filtering phase, and a near-query effectively behaves like an and-query unfiltered. That likely includes false positives, which can turn into false negatives when wrapped in a not-query.
Cheers, Geert On 12/23/15, 4:50 PM, "[email protected] on behalf of "neil bradley"" <[email protected] on behalf of [email protected]> wrote: >I am having a probkem with using near queries within not queries when >the queries are stored and used in a reverse query. > >This fails, no matter how far apart "bad" and "word" are. The distance >value seems to be ignored. The query will not return the stored query >even if the words "bad" and "word" are hundreds of words apart. > >let $XMLQuery := ><cts:and-query xmlns:cts="http://marklogic.com/cts"> > <cts:not-query> > <cts:near-query distance="2"> > <cts:word-query><cts:text >xml:lang="en">bad</cts:text></cts:word-query> > <cts:word-query><cts:text >xml:lang="en">word</cts:text></cts:word-query> > </cts:near-query> > </cts:not-query> > <cts:or-query> > <cts:word-query><cts:text >xml:lang="en">red</cts:text></cts:word-query> > <cts:word-query><cts:text >xml:lang="en">yellow</cts:text></cts:word-query> > </cts:or-query> ></cts:and-query> >let $File := xdmp:document-insert("test.xml", ><Query>{$XMLQuery}</Query>) >return > ( ) > > ; > >let $XML := <X>this contains yellow, with a bad a a a a a a word.</X> >return > cts:search( /Query, cts:reverse-query($XML)) > > >But strangely, when I do something similar in memory, it works fine. >So this returns "true" as I would expect: > >let $XMLQuery := ... >let $XML := <X>this contains yellow, with a bad a a a a a a word.</X> >return > cts:contains(cts:query($XMLQuery), cts:reverse-query($XML)) > >And this returns "false", as I would also expect because the words are >close together, so should prevent the match... > > let $XML := <X>this contains yellow, with a bad a word.</X> > > >Neil. >_______________________________________________ >General mailing list >[email protected] >Manage your subscription at: >http://developer.marklogic.com/mailman/listinfo/general _______________________________________________ General mailing list [email protected] Manage your subscription at: http://developer.marklogic.com/mailman/listinfo/general
