Good afternoon,
I observed that GETting /v1/search?collection=<coll>&structuredQuery=<q>
does not filter the results to the collection-members in ML9.
/v1/search?collection=<coll> does what I'd expect from it, and moving the
collection constraint into structuredQuery also works as advertised.
In ML8 the first version above also observes teh query and the collection
filter. The two databases are constructed with teh same properties.
Is there an explanation for this behaviour or is this a bug?
I've tested this with a minimal example which I have attached below.
Thanks,
David
#!/bin/sh
#console ML9:
#xdmp:document-insert("coll-test-1.xml",<coll-test>1</coll-test>,map:new(map:entry("collections","coll-test-1")))
#xdmp:document-insert("coll-test-2.xml",<coll-test>2</coll-test>,map:new(map:entry("collections","coll-test-2")))
#works as expected:
#cts:search(collection("coll-test-1"),cts:element-query(xs:QName("coll-test"),cts:and-query(())))
#cts:search(doc(),cts:element-query(xs:QName("coll-test"),cts:collection-query("coll-test-1")))
#console ML8:
#xdmp:document-insert("coll-test-1.xml",<coll-test>1</coll-test>,(),("coll-test-1")),
#xdmp:document-insert("coll-test-2.xml",<coll-test>2</coll-test>,(),("coll-test-2"))
#works as expected:
#cts:search(collection("coll-test-1"),cts:element-query(xs:QName("coll-test"),cts:and-query(())))
#cts:search(doc(),cts:element-query(xs:QName("coll-test"),cts:collection-query("coll-test-1")))
# Search results below are elided for brevity, search:metric , search:snippet
removed, also some attributes
#ML9
# asking for collection and document structure. This query is returning the
wrong results, disregarding the collection parameter
q="<cts:element-query
xmlns:cts='http://marklogic.com/cts'><cts:element>coll-test</cts:element><cts:and-query
/></cts:element-query>"
curl -s --data-urlencode -v -i --anyauth -u user:pwd -X GET
"http://marklogic-9:9001/v1/search?collection=coll-test-1&structuredQuery=${q}"
<search:response snippet-format="snippet" total="2" start="1" page-length="10"
xmlns:search="http://marklogic.com/appservices/search">
<search:result index="1" uri="coll-test-1.xml"
href="/v1/documents?uri=coll-test-1.xml">
</search:result>
<search:result index="2" uri="coll-test-2.xml"
href="/v1/documents?uri=coll-test-2.xml">
</search:result>
</search:response>
#asking for collection only:
curl -s --data-urlencode -v -i --anyauth -u user:pwd -X GET
"http://marklogic-9:9001/v1/search?collection=coll-test-1"
<search:response snippet-format="snippet" total="1" start="1" page-length="10"
xmlns:search="http://marklogic.com/appservices/search">
<search:result index="1" uri="coll-test-1.xml
href="/v1/documents?uri=coll-test-1.xml">
</search:result>
</search:response>
# referring to collection in cts:query
q="<cts:element-query
xmlns:cts='http://marklogic.com/cts'><cts:element>coll-test</cts:element><cts:collection-query><cts:uri>coll-test-1</cts:uri></cts:collection-query></cts:element-query>"
curl -s --data-urlencode -v -i --anyauth -u user:pwd -X GET
"http://marklogic-9:9001/v1/search?structuredQuery=${q}"
<search:response snippet-format="snippet" total="1" start="1" page-length="10"
xmlns:search="http://marklogic.com/appservices/search">
<search:result index="1" uri="coll-test-1.xml"
href="/v1/documents?uri=coll-test-1.xml">
</search:result>
</search:response>
#ML8 for comparison
# asking for collection and document structure. On ML8 this works as
expected/documented
q="<cts:element-query
xmlns:cts='http://marklogic.com/cts'><cts:element>coll-test</cts:element><cts:and-query
/></cts:element-query>"
curl -s --data-urlencode -v -i --anyauth -u user:pwd -X GET
"http://marklogic-8:9001/v1/search?collection=coll-test-1&structuredQuery=${q}"
<search:response snippet-format="snippet" total="1" start="1" page-length="10"
xmlns:search="http://marklogic.com/appservices/search">
<search:result index="1" uri="coll-test-1.xml"
href="/v1/documents?uri=coll-test-1.xml">
</search:result>
</search:response>
_______________________________________________
General mailing list
[email protected]
Manage your subscription at:
http://developer.marklogic.com/mailman/listinfo/general