Hi, Gnanaprakash:

The signature for a custom snippeting transform is different from the
signature for a document transform (which is what you show below).
For the signature for a snippeting transform, please see:

    http://docs.marklogic.com/guide/search-dev/search-api#id_61707

Also, you can apply either the built-in logic to get the entire document
or a custom snippeting transform to get the desired snippet but not both:

    http://docs.marklogic.com/guide/search-dev/search-api#id_36346

To get the search results structures as JSON and get every individual
document in the search results as JSON, I can think of a few approaches:

1.  Get the search results as JSON with empty snippets (that is, with
     search options containing <transform-results apply="empty-snippet"/>
     and, on the client, issue a separate request for each document
     that applies the document transform.

2.  Create a custom snippeting transform that returns a search:snippet
     element containing the output from passing the XML result document
     to json:transform-to-json().  In the client search request, get the search
     results as JSON, specifying the custom snippetting transform.  Then,
     on the client, parse the snippet string as JSON.

3.  Create a resource services extension that takes a search request,
     calls search:search() (again with empty snippets) to get the list
     of documents, use fn:doc() to get each document, and apply
     the json:transform-to-json() to each document.

     A resource services extension can define a new REST resource
     or new services for existing resources.  For more information
     about this advanced capability, please see:

     http://docs.marklogic.com/guide/rest-dev/extensions#id_41710

4.  Get the search results and documents as XML and either process
     the results as XML or transform the results to JSON on the client.

For improving the REST API, my take-away is that there are scenarios
where it is important to transform the entire search results structure
on the server.


Hoping that's useful,


Erik Hennum

________________________________
From: [email protected] 
[[email protected]]
Sent: Monday, December 31, 2012 5:27 AM
To: [email protected]; Erik Hennum
Subject: RE: Issue with ML6 XQuery Transformation

Hi Erik,

Can you please help me out in this. There seems to be an issue in custom 
transformation parameter sequence.

Regards,
Gnanaprakash Bodireddy.

From: Bodireddy, Gnanaprakash (Cognizant)
Sent: Thursday, December 27, 2012 11:07 AM
To: [email protected]
Subject: Issue with ML6 XQuery Transformation

Hi

I am facing an issue in using custom XQuery Transformation which I am currently 
using in Rest-API Search

http://<<Host>>:9000/v1/search?q=&options=levelTransformation<UrlBlockedError.aspx>

levelTransformation is configured as below:
<options xmlns="http://marklogic.com/appservices/search";>
<transform-results apply="raw" 
ns="http://marklogic.com/rest-api/transform/levelTransformation"; 
at="/level-transformation.xqy"/>
</options>

Module: /level-transformation.xqy
xquery version "1.0-ml";
module namespace level-transform = 
"http://marklogic.com/rest-api/transform/levelTransformation";;

declare function level-transform:raw(
  $context as map:map,
  $params as map:map,
  $content as document-node()
)
{
…….
};

In the above module when used I am facing issue as $context is getting document 
content which is failing as it’s taken as map:map , $content is empty and 
$params is having transformation configuration.

After trying  a lot I figured that $context and $content are getting swapped. 
Is this an issue? Or am I doing something wrong here?

Can I get some help here as I am getting XML document (raw) in $context which 
is not as per documentation 
(http://docs.marklogic.com/guide/rest-dev/transforms#id_17421)

Thanks and Regards,

Gnanaprakash Bodireddy
Sr Associate - Projects | IME
Cognizant Technology Solutions
VNET: 672103
(O): +91 (40) 44514444 extn: 672103
(M): +91-8897575644

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

Reply via email to