Hi, Gnanaprakash: Good to hear you're making progress.
XML and JSON have fundamentally different models. Some XML cases have no natural representation in JSON and vice versa. That fundamental mismatch means that there is no standard transform from XML to JSON. (You can search to see some of the alternatives, each of which uses some form of tunnelling for structures that don't fit the JSON model.) As a result, the REST API can only provide out-of-the-box JSON conversion for the XML structures produced directly by MarkLogic. The REST API can't provide JSON conversion for every possible XML document stored in the database. That's a consequence of the XML and JSON mismatch instead of a limitation of MarkLogic. You could write an XSLT or XQuery transform extension to implement the transform from your XML vocabulary to JSON. You could then search to get the document URIs and iterate over the documents to get the transformed documents. Or, you could write a resource services extension that does the search and transform entirely on the server. If you want to work with JSON documents, however, the simplest approach would be to store JSON documents in the database instead of XML documents. Hoping that helps, Erik Hennum ________________________________ From: [email protected] [[email protected]] Sent: Monday, December 24, 2012 4:31 AM To: Erik Hennum; [email protected] Subject: RE: Reg Retrieving full document while performing search Hi Erik Thanks for the help. I have created the options and it worked fine for me. But I got results which is slightly deviating from my expectation. Options: custom-search <options xmlns="http://marklogic.com/appservices/search"> <transform-results apply="raw"/> </options> URL: http://<<Host>>:9000/v1/search?q=&options=custom-search&format=json<UrlBlockedError.aspx> Result (JSON): { snippet-format: "raw", total: 28252, start: 1, page-length: 10, results: [ { index: 1, uri: "/Test_1.xml", path: "fn:doc("/Test_1.xml")", score: 0, confidence: 0, fitness: 0, content: "<sample id="123"><name>Gnana</name><address>abc</address></sample>" }, { index: 2, uri: "/Test_2.xml", path: "fn:doc("/Test_2.xml")", score: 0, confidence: 0, fitness: 0, content: "<sample id="456"><name>Prakash</name><address>abc</address></sample>" }, ... ] } I am expecting even the content to be shown in JSON. Is there any way I can transform this content node into JSON? Thanks and Regards, Gnanaprakash Bodireddy -----Original Message----- From: Erik Hennum [mailto:[email protected]] Sent: Friday, December 21, 2012 8:08 PM To: Bodireddy, Gnanaprakash (Cognizant) Subject: RE: Reg Retrieving full document while performing search Hi, Gnanaprakash: You don't pass in transform-results as a URI parameter. Instead, you configure query options on the server before you search. To find out how to write query options to the server, please see: http://docs.marklogic.com/guide/rest-dev/search#id_48838 To find out more about the query options supported by the server, please see: http://docs.marklogic.com/guide/search-dev/search-api#id_36346 http://docs.marklogic.com/search:search#opt-transform-results Erik Hennum ________________________________________ From: [email protected]<mailto:[email protected]> [[email protected]] Sent: Friday, December 21, 2012 5:24 AM To: Erik Hennum Subject: RE: Reg Retrieving full document while performing search HI Erik Can you please help me in how I can pass transform-results as options in URL. Do I need to configure anything before passing transform-results? The below one is not working for me. http://<<Host>>:9000/v1/search?q=&format=xml&options=transform-results:raw<UrlBlockedError.aspx> Thanks and Regards, Gnanaprakash Bodireddy >> You can modify your query options to specify transform-results of apply="raw". By the way, you can also use extract-metadata in your query options to get fragments of the result document independent of whether the fragment contained a match on the criteria. Erik Hennum This e-mail and any files transmitted with it are for the sole use of the intended recipient(s) and may contain confidential and privileged information. If you are not the intended recipient(s), please reply to the sender and destroy all copies of the original message. Any unauthorized review, use, disclosure, dissemination, forwarding, printing or copying of this email, and/or any action taken in reliance on the contents of this e-mail is strictly prohibited and may be unlawful. This e-mail and any files transmitted with it are for the sole use of the intended recipient(s) and may contain confidential and privileged information. If you are not the intended recipient(s), please reply to the sender and destroy all copies of the original message. Any unauthorized review, use, disclosure, dissemination, forwarding, printing or copying of this email, and/or any action taken in reliance on the contents of this e-mail is strictly prohibited and may be unlawful.
_______________________________________________ General mailing list [email protected] http://developer.marklogic.com/mailman/listinfo/general
