Hi, We've noticed some unusual behaviour when performing a cts:search with a specific set of ANDed queries, in that the order of the queries is important. If the order of the queries is reversed, the search returns different results.
Please find below some sample searches; the one with the unusual behaviour is labelled (: failure case :), which has the following characteristics: * Two element value queries against the same element * A NOT query against a property The search is successful when the NOT query is the last query; however, if the NOT query is the first, or second query, then the search is not successful. Other searches with different variations (e.g. where the element value queries are against different elements) are fine; the order of the individual queries does not affect the results. Any suggestions on this would be much appreciated - we'd like to know if there's a genuine (and expected) reason why this would be happening, or if there's an issue with cts:search. Is it the case that the order of ANDed queries could be important, in certain situations? Thanks, Richard XQuery: declare namespace ns = "https://and/query/fail"; (: set up - note that this should be done *before* the queries below, to give the indexes time to catch up :) let $content := <content xmlns="https://and/query/fail"> <one>this</one> <two>that</two> </content> let $doc := xdmp:document-insert("/querytest/x", $content) let $props := xdmp:document-set-property("/querytest/x", <three>other</three>) (: failure case - this is expected to return consistent results, irrespective of the order of the individual queries, but doesn't :) let $elements-same-not-properties-query := ( cts:element-value-query((xs:QName("ns:one")), "this"), cts:element-value-query((xs:QName("ns:one")), "this"), cts:not-query(cts:properties-query(cts:element-value-query(xs:QName("three"), "xxx")))) (: but this one works - there is only one element value query :) let $one-elements-not-properties-query := ( cts:element-value-query((xs:QName("ns:one")), "this"), cts:not-query(cts:properties-query(cts:element-value-query(xs:QName("three"), "xxx")))) (: this also works - the first two queries are against different elements :) let $elements-different-not-properties-query := ( cts:element-value-query((xs:QName("ns:one")), "this"), cts:element-value-query((xs:QName("ns:two")), "that"), cts:not-query(cts:properties-query(cts:element-value-query(xs:QName("three"), "xxx")))) (: this also works - it's a positive query, not a NOT query :) let $elements-same-positive-properties-query := ( cts:element-value-query((xs:QName("ns:one")), "this"), cts:element-value-query((xs:QName("ns:one")), "this"), cts:properties-query(cts:element-value-query(xs:QName("three"), "other"))) (: this also works - the NOT query is against an element instead of a property :) let $elements-same-not-element-query := ( cts:element-value-query((xs:QName("ns:one")), "this"), cts:element-value-query((xs:QName("ns:one")), "this"), cts:not-query(cts:element-value-query(xs:QName("ns:two"), "xxx"))) (: try each set of AND queries in normal order, and reverse order - the results should be consistent :) return <result> <elements-same-not-properties-query> <normal> { cts:search(doc(), cts:and-query($elements-same-not-properties-query)) } </normal> <reversed> { cts:search(doc(), cts:and-query(reverse($elements-same-not-properties-query))) } </reversed> </elements-same-not-properties-query> <one-element-not-properties-query> <normal> { cts:search(doc(), cts:and-query($elements-different-not-properties-query)) } </normal> <reversed> { cts:search(doc(), cts:and-query(reverse($elements-different-not-properties-query))) } </reversed> </one-element-not-properties-query> <elements-different-not-properties-query> <normal> { cts:search(doc(), cts:and-query($elements-different-not-properties-query)) } </normal> <reversed> { cts:search(doc(), cts:and-query(reverse($elements-different-not-properties-query))) } </reversed> </elements-different-not-properties-query> <elements-same-positive-properties-query> <normal> { cts:search(doc(), cts:and-query($elements-same-positive-properties-query)) } </normal> <reversed> { cts:search(doc(), cts:and-query(reverse($elements-same-positive-properties-query))) } </reversed> </elements-same-positive-properties-query> <elements-same-not-element-query> <normal> { cts:search(doc(), cts:and-query($elements-same-not-element-query)) } </normal> <reversed> { cts:search(doc(), cts:and-query(reverse($elements-same-not-element-query))) } </reversed> </elements-same-not-element-query> </result>
_______________________________________________ General mailing list [email protected] http://developer.marklogic.com/mailman/listinfo/general
