marklogic/java-client-api

Marklogic v1/search has issues when returning result in JSON based on header accept=application/json, when underlaying documents are stored in XML

sreehesh opened this issue · 1 comments

So we can address your issue, please include the following:
###MarkLogic 10.x
See Readme.txt

Version of MarkLogic Server

REST Endpoint: /LATEST/search
header parameter

Accept=application/json or search parameter rs:format=json

Input: Some code to illustrate the problem, preferably in a state that can be independently reproduced on our end

Following is my search option file, that also have snippet defined to customize the response.

customer-organization case-insensitive

Actual output: What did you observe? What errors did you see? Can you attach the logs? (Java logs, MarkLogic logs)

{
"snippet-format": "snippeter",
"total": 2,
"start": 1,
"page-length": 10,
"results": [
{
"index": 1,
"uri": "/mdm/party/908839521717560922.xml",
"path": "fn:doc("/mdm/party/908839521717560922.xml")",
"score": 221184,
"confidence": 0.619787,
"fitness": 1,
"href": "/v1/documents?uri=%2Fmdm%2Fparty%2F908839521717560922.xml",
"mimetype": "application/xml",
"format": "xml",
"matches": null
},
{
"index": 2,
"uri": "/mdm/party/232239515116761043.xml",
"path": "fn:doc("/mdm/party/232239515116761043.xml")",
"score": 212992,
"confidence": 0.6082011,
"fitness": 1,
"href": "/v1/documents?uri=%2Fmdm%2Fparty%2F232239515116761043.xml",
"mimetype": "application/xml",
"format": "xml",
"matches": null
},
"qtext": "marketableProduct:xyz ",
"metrics": {
"query-resolution-time": "PT0.021202S",
"facet-resolution-time": "PT0.028157S",
"snippet-resolution-time": "PT7.708948S",
"total-time": "PT8.297156S"
}
}

Expected output: What specifically did you expect to happen?

The "matches" property should contain document content.

Alternatives: What else have you tried, actual/expected?

I tried to write custom snippet to convert XML to JSON, to resolve this issue. But I am not able to let my snippet know if the user want XML response or JSON response, based on the input parameter rs:format value or Accept parameter as these parameters are accessible in the custom snippet.

@sreehesh , This GitHub repository has the source code and issues specific to the MarkLogic Java API.

For issues with MarkLogic Server including the MarkLogic REST API, please work with the MarkLogic support contact in your organization to report an issue with MarkLogic Support.