Closed sravanr closed 4 years ago
To keep my bug simple, I always see "results" object in search handle of bulk search.
Erik, I'm assigning this one to you because it appears the error is in the REST API. Looking at the wire output, we're requesting GET /v1/search?category=content&q=bar&format=json&view=metadata&pageLength=50 yet we're getting results in the search payload, not just metadata as we would expect.
Please try category=metdata instead of view=metadata (either with or without category=content)
I'm wondering if we're talking about the same thing. I'm talking about an ability to retrieve only facets, or results, or metadata in the search payload. I thought category was about what to retrieve as bulk parts outside the search payload. In any case, how should you specify that you want only facets or results or metadata in the search payload? Strangely, I get the expected behavior when I don't match anything, but as soon as I match something I get results in the search payload every time. Match nothing with view=results behaves properly and has "results":[]:
curl --digest --user rest-writer:x -H "Content-Type: application/xml" -H "Accept: multipart/mixed" -X GET 'http://localhost:8012/v1/search?category=content&q=bar&format=json&view=results&pageLength=50'
Content-type: multipart/mixed; boundary=ML_BOUNDARY_5234745991537538125
vnd.marklogic.start: 1
vnd.marklogic.pageLength: 50
vnd.marklogic.result-estimate: 0
Server: MarkLogic
Content-Length: 353
Connection: Keep-Alive
Keep-Alive: timeout=5
--ML_BOUNDARY_5234745991537538125
Content-Type: application/json
Content-Disposition: inline
Content-Length: 195
{"snippet-format":"snippet","total":0,"start":1,"page-length":50,"results":[],"qtext":"bar","metrics":{"query-resolution-time":"PT0.02S","snippet-resolution-time":"PT0S","total-time":"PT0.021S"}}
--ML_BOUNDARY_5234745991537538125--
Match nothing with view=metadata behaves properly and has no "results":[]:
curl --digest --user rest-writer:x -H "Content-Type: application/xml" -H "Accept: multipart/mixed" -i -X GET 'http://localhost:8012/v1/search?category=content&q=bar&format=json&view=metadata&pageLength=50'
HTTP/1.1 200 OK
Content-type: multipart/mixed; boundary=ML_BOUNDARY_17646232257794988794
vnd.marklogic.start: 1
vnd.marklogic.pageLength: 50
vnd.marklogic.result-estimate: 0
Server: MarkLogic
Content-Length: 308
Connection: Keep-Alive
Keep-Alive: timeout=5
--ML_BOUNDARY_17646232257794988794
Content-Type: application/json
Content-Disposition: inline
Content-Length: 148
{"snippet-format":"snippet","total":0,"start":1,"page-length":50,"qtext":"bar","metrics":{"snippet-resolution-time":"PT0S","total-time":"PT0.022S"}}
--ML_BOUNDARY_17646232257794988794--
Match something with view=metadata does not behave properly and has a "results":[]:
curl --digest --user rest-writer:x -H "Content-Type: application/xml" -H "Accept: multipart/mixed" -i -X GET 'http://localhost:8012/v1/search?category=content&q=a&format=json&view=metadata&pageLength=50'
HTTP/1.1 200 OK
Content-type: multipart/mixed; boundary=ML_BOUNDARY_4020778783712915816
vnd.marklogic.start: 1
vnd.marklogic.pageLength: 50
vnd.marklogic.result-estimate: 6
Server: MarkLogic
Content-Length: 4093
Connection: Keep-Alive
Keep-Alive: timeout=5
--ML_BOUNDARY_4020778783712915816
Content-Type: application/json
Content-Disposition: inline
Content-Length: 2015
{"snippet-format":"snippet","total":6,"start":1,"page-length":50,"results":[{"index":1,"uri":"2.json","path":"fn:doc(\"2.json\")","score":59136,"confidence":0.44145,"fitness":0.8028674,"href":"/v1/documents?uri=2.json","mimetype":"application/json","format":"json","matches":[{"path":"fn:doc(\"2.json\")","match-text":[]}]},{"index":2,"uri":"4.json","path":"fn:doc(\"4.json\")","score":43008,"confidence":0.3764698,"fitness":0.6846876,"href":"/v1/documents?uri=4.json","mimetype":"application/json","format":"json","matches":[{"path":"fn:doc(\"4.json\")","match-text":[]}]},{"index":3,"uri":"/test/testWrite1.txt","path":"fn:doc(\"/test/testWrite1.txt\")","score":43008,"confidence":0.3764698,"fitness":0.6846876,"href":"/v1/documents?uri=%2Ftest%2FtestWrite1.txt","mimetype":"text/plain","format":"text","matches":[{"path":"fn:doc(\"/test/testWrite1.txt\")/text()","match-text":[{"highlight":"A"}," simple text document"]}]},{"index":4,"uri":"/test/testMetadataXML1.xml","path":"fn:doc(\"/test/testMetadataXML1.xml\")","score":43008,"confidence":0.3764698,"fitness":0.6846876,"href":"/v1/documents?uri=%2Ftest%2FtestMetadataXML1.xml","mimetype":"text/xml","format":"xml","matches":[{"path":"fn:doc(\"/test/testMetadataXML1.xml\")/root","match-text":["\n",{"highlight":"A"}," simple XML document\n"]}]},{"index":5,"uri":"1.json","path":"fn:doc(\"1.json\")","score":43008,"confidence":0.3764698,"fitness":0.6846876,"href":"/v1/documents?uri=1.json","mimetype":"application/json","format":"json","matches":[{"path":"fn:doc(\"1.json\")","match-text":[]}]},{"index":6,"uri":"/test/testMetadataXML2.xml","path":"fn:doc(\"/test/testMetadataXML2.xml\")","score":43008,"confidence":0.3764698,"fitness":0.6846876,"href":"/v1/documents?uri=%2Ftest%2FtestMetadataXML2.xml","mimetype":"text/xml","format":"xml","matches":[{"path":"fn:doc(\"/test/testMetadataXML2.xml\")/root","match-text":["\n",{"highlight":"A"}," simple XML document\n"]}]}],"qtext":"a","metrics":{"snippet-resolution-time":"PT0.014S","total-time":"PT0.03S"}}
--ML_BOUNDARY_4020778783712915816
Content-Type: application/json
Content-Disposition: attachment; filename="2.json"; category=content; format=json
Content-Length: 172
{"root":{"title":"The Bush article", "popularity":"4", "id":"0012", "date":"2006-02-02", "price":{"amt":"0.12"}, "p":"The Bush article described a device called a Memex."}}
--ML_BOUNDARY_4020778783712915816
Content-Type: application/json
Content-Disposition: attachment; filename="4.json"; category=content; format=json
Content-Length: 188
{"root":{"title":"Vannevar served", "popularity":"5", "id":"0024", "date":"2008-04-04", "price":{"amt":"12.34"}, "p":"Vannevar served as a prominent policymaker and public intellectual."}}
--ML_BOUNDARY_4020778783712915816
Content-Type: text/plain
Content-Disposition: attachment; filename="/test/testWrite1.txt"; category=content; format=text
Content-Length: 22
A simple text document
--ML_BOUNDARY_4020778783712915816
Content-Type: application/xml
Content-Disposition: attachment; filename="/test/testMetadataXML1.xml"; category=content; format=xml
Content-Length: 136
<?xml version="1.0" encoding="UTF-8"?>
<root mode="mixed" xml:lang="en">
<child mode="basic">value</child>
A simple XML document
</root>
--ML_BOUNDARY_4020778783712915816
Content-Type: application/json
Content-Disposition: attachment; filename="1.json"; category=content; format=json
Content-Length: 172
{"root":{"title":"Vannevar Bush", "popularity":"5", "id":"0011", "date":"2005-01-01", "price":{"amt":"0.1"}, "p":"Vannevar Bush wrote an article for The Atlantic Monthly"}}
--ML_BOUNDARY_4020778783712915816
Content-Type: application/xml
Content-Disposition: attachment; filename="/test/testMetadataXML2.xml"; category=content; format=xml
Content-Length: 136
<?xml version="1.0" encoding="UTF-8"?>
<root mode="mixed" xml:lang="en">
<child mode="basic">value</child>
A simple XML document
</root>
--ML_BOUNDARY_4020778783712915816--
One question is whether the query options (either explicit or the default for the REST server) has return-results of false. If it does, the bulk request is buggy at the REST API level.
Here is the content of /Default/java-unittest/rest-api/options/default.xml in java-unittest-modules (the db I'm testing against):
<?xml version="1.0" encoding="UTF-8"?>
<options xmlns="http://marklogic.com/appservices/search">
<search-option>unfiltered</search-option>
<quality-weight>0</quality-weight>
</options>
Depends on a fix in the REST API (28819)
28819 is fixed, so I believe this is fixed
setSearchView(QueryView.METADATA); and look at the search handle and I always see the results instead of seeing only metadata.
I see both QueryManager search request and BulkSearch REST request are same and I feel this could be an issue with REST or my lack of understanding "GET /v1/search?category=content&q=bar&format=json&view=metadata& vs "GET /v1/search?q=bar&view=metadata HTTP/1.1[\r][\n]"
below is my test