Re: [FT] ftnot of no matches

Paul J. Lucas wrote:
> In 4.2.6.3 of the XQuery Full Text spec, the semantics seem clear enough.
> However, what's not clear is how ftnot works when there are no matches to begin with.
> 
> Given:
> 
> 	let $x := <msg>hello, world</msg>
> 	return $x contains text ftnot "goodbye"
> 
> It's clear that the XML document does not contain "goodbye".
> Hence, the matchTokenInfos() function will return no TokenInfo objects and,
> subsequently, applyQueryTokensAsPhrase() will return an empty <allMatches/>.
> 
> Calling ApplyFTUnaryNot() on <allMatches/> will do nothing since there are
> no stringIncludes to flip to stringExcludes and vice versa.

Not quite nothing. Note the first few lines of fts:UnaryNotHelper():

     if (fn:empty($matches))
     then <fts:match/>
     else ...

Thus, calling ApplyFTUnaryNot() on <allMatches/> yields
     <allMatches><match/></allMatches>

which will cause the FTContainsExpr to yield true, as you expect.

-Michael

Received on Tuesday, 8 June 2010 07:28:18 UTC