0
votes

I am using options file (loaded into modules DB using PUT /v1/config/query). Then I do a GET /v1/search with ?options=module-name&q=FullName:"John Smith". I am trying to pass FullName that is supplied as a parameter through REST API, to restrict the output content.

Below code in options file works fine,

<extract-document-data selected="include">
    <extract-path>/envelope/instance/Contact/*[FullName="John Smith"] 
    </extract-path>
</extract-document-data>

How can I pass the value of FullName as a parameter with the value coming from REST API prameters instead of hard-coding? Something like,

<extract-document-data selected="include">
    <extract-path>/envelope/instance/Contact/*[FullName=$FullName] 
    </extract-path>
</extract-document-data>

I tried above syntax but getting error while deployment(PUT /v1/config/query).

{"errorResponse": { "statusCode": 400, "status": "Bad Request", "messageCode": "RESTAPI-INVALIDCONTENT", "message": "RESTAPI-INVALIDCONTENT: (err:FOER0000) Invalid content: invalid paths to extract document data: /envelope/instance/Contact/*[FullName=$FullName]" }}

2

2 Answers

1
votes

Instead of loading the options in advance, you can send the options with the query in the request. See:

http://docs.marklogic.com/guide/rest-dev/search#id_69918

Before sending the request, the client can substitute the actual fullname in the extract path value.

The request can provide the query string in the qtext element.

Hoping that helps,

0
votes

Alternatively, you could simply extract all full names, and either filter client-side, or write a REST transform that takes a trans: parameter to do the filtering for you server-side.

HTH!