Thanks for the explanation Mike.
I've found skipping the first result is insufficient because the input node
isn't guaranteed to be the first result. The best solution seems to be:
let $uri := '/test.xml'
return cts:search(fn:doc(), cts:and-not-query(
cts:similar-query(fn:doc($uri)),
cts:document-query($uri)
))[1 to 10]
-----Original Message-----
From: Michael Blakeley [mailto:[email protected]]
Sent: 28 January 2010 16:27
To: General Mark Logic Developer Discussion
Cc: Whitby, Rob, Springer Healthcare
Subject: Re: [MarkLogic Dev General] similar query returning same document
Rob,
The behavior you describe is the behavior I would expect. If the similar-query
input node is a database document, then it will be most similar to itself. Keep
in mind that the input nodes don't have to be database documents, so it
wouldn't make sense for the server to automatically skip the first match.
However, if you do not wish to display that first document to the user, simply
skip over it and begin display from the second result.
-- Mike
On 2010-01-28 04:37, Whitby, Rob, Springer Healthcare wrote:
> Hi
>
> I’m getting odd results from cts:similar-query where the first result it
> returns is the same document:
>
> let $uri := '/test.xml'
> let $similar := fn:document-uri(cts:search(fn:collection(),
> cts:similar-query(fn:doc($uri)))[1])
> return (
> $uri,
> $similar,
> fn:compare($uri, $similar)
> )
>
> ==>
>
> /test.xml
> /test.xml
> 0
>
>
> Any ideas?
>
> Thanks
> Rob
>
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general