I'd leave out the extra cts:and-query. A near-query is pretty much an and-query 
with distance options anyway.

But looking at the xdmp:plan output, I think the extra and-query gets optimized 
away. This is a 7.0-2.3 database with most of the position options enabled.

deep-equal(
  xdmp:plan(
    cts:search(
      fn:doc(),
      cts:near-query(
        cts:and-query(
          (cts:word-query("cat"), cts:word-query("dog"))),
        1000,
        (),
        3)))/
  *:final-plan,
  xdmp:plan(
    cts:search(
      fn:doc(),
      cts:near-query(
        (cts:word-query("cat"), cts:word-query("dog")),
        1000,
        (),
        3)))/
  *:final-plan)
=> true()

-- Mike

On 30 May 2014, at 12:01 , Steiner, David J. (LNG-DAY) 
<[email protected]> wrote:

> In the documentation: 
> http://docs.marklogic.com/guide/search-dev/relevance#id_85289
>  
> The suggestion is to use the following to achieve a result that limits the 
> distance between the words:
> xquery version "1.0-ml";
> cts:search(fn:doc(),
>    cts:near-query(
>      cts:and-query((
>         cts:word-query("cat"),
>         cts:word-query("dog") )),
>      1000, (), 3) )
>  
> I’m trying to figure out what the difference is between that query and this 
> query, with regards to the type of results I could get:
> xquery version "1.0-ml";
> cts:search(fn:doc(),
>    cts:near-query(
>      (cts:word-query("cat"),
>         cts:word-query("dog") ),
>      1000, (), 3) )
>  
> So far, I can’t figure out what would I’d get with one that I wouldn’t get 
> with the other.  I even added 4 more sample docs, one with only “dog”, one 
> with only “cat”, one with “cat” near “cat” and one with “dog” near “dog”.  
> Whether I make the distance 1, 5, 10 and the weight 0, 1, 3, I get the same 
> results regardless of which I run.  If there’s something I should get with 
> one or the other, what would the “document” look like?
> 
> Thanks,
> David 
> _______________________________________________
> General mailing list
> [email protected]
> http://developer.marklogic.com/mailman/listinfo/general

_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to