I am using Roxy to manage my project. Also using MarkLogic 8.0-6.1

I am trying to submit a searchTerm, and return a custom formatted `search:snippet`

Here are the complete steps that I am taking:

`./../roxy/ml new test-app --server-version=8 --app-type=rest`

Configure my build.properties

`cd test-app/`
`./ml local bootstrap`

Now I have my project Structure.

Create File - test-app/rest-api/ext/show-search.xqy 

```
xquery version "1.0-ml";

module namespace ss = "http://marklogic.com/rest-api/resource/show-search";
import module namespace search = "http://marklogic.com/appservices/search" at "/MarkLogic/appservices/search/search.xqy";
import module namespace json = "http://marklogic.com/xdmp/json" at "/MarkLogic/json/json.xqy";

declare
function ss:get(
  $context as map:map,
  $params  as map:map
) as document-node()*
{

  map:put($context, "output-types", "application/json"),
  map:put($context, "output-status", (200, "OK")),

  let $search-term := map:get($params, "searchTerm")
  let $query := search:search($search-term,
      <options xmlns="http://marklogic.com/appservices/search">
        <transform-results apply="raw"/>
      </options>
      )

  return document {$query} 
};

(:
 :)
declare 
function ss:put(   
    $context as map:map,
    $params  as map:map,
    $input   as document-node()*
) as document-node()?
{
  map:put($context, "output-types", "application/xml"),
  map:put($context, "output-status", (201, "Created")),
  document { "PUT called on the ext service extension" }
};

(:
 :)
declare 
function ss:post(
    $context as map:map,
    $params  as map:map,
    $input   as document-node()*
) as document-node()*
{
  map:put($context, "output-types", "application/xml"),
  map:put($context, "output-status", (201, "Created")),
  document { "POST called on the ext service extension" }
};

(:
 :)
declare 
function ss:delete(
    $context as map:map,
    $params  as map:map
) as document-node()?
{
  map:put($context, "output-types", "application/xml"),
  map:put($context, "output-status", (200, "OK")),
  document { "DELETE called on the ext service extension" }
};

```

The above GET request uses the `transform-results apply=raw` option, deploys, and functions properly (I have some test documents).

However I do not want to return the whole document, I want to return a whole section of the json that had a match, no matter where in that seciton the match happened (lower levels)

So I try to write my own `snipper`

Create File - test-app/rest-api/ext/show-search-snipper.xqy

```
xquery version "1.0-ml";

module namespace sss = "http://marklogic.com/rest-api/resource/show-search-snipper";
import module namespace search = "http://marklogic.com/appservices/search" at "/MarkLogic/appservices/search/search.xqy";
import module namespace json = "http://marklogic.com/xdmp/json" at "/MarkLogic/json/json.xqy";

declare
function sss:my-snippet(
    $result as node(),
    $ctsquery as schema-element(cts:query),
    $options as element(search:transform-results)?
) as element(search:snippet)
{
    <search:snippet>

    </search:snippet>
};

```

I then update the `search:search` call to the following

```
  let $query := search:search($search-term,
      <options xmlns="http://marklogic.com/appservices/search">
        <transform-results apply="my-snippet" ns="http://marklogic.com/rest-api/resource/show-search-snipper" at="show-search-snipper.xqy"/>
      </options>
      )

```

Now I should have everything I need (I think)

I run the deploy `./ml local deploy rest`

and get the following 

> 
> Minty-linux test-app # ./ml local deploy rest Loading REST properties
>  in /opt/this-is-a-test/test-app/rest-api/config/properties.xml Loading
>  REST options in /opt/this-is-a-test/test-app/rest-api/config/options
> 
> 
> Loading REST extensions from /opt/this-is-a-test/test-app/rest-api/ext
> 
> 
> ERROR: 400 "Bad Request" ERROR: {"errorResponse":{"statusCode":400,
>  "status":"Bad Request", "messageCode":"RESTAPI-INVALIDCONTENT",
>  "message":"RESTAPI-INVALIDCONTENT: (err:FOER0000) Invalid content:
>  invalid show-search-snipper extension: show-search-snipper either is
>  not a valid module or does not provide extension functions (delete,
>  get, put, post) in the
>  <http://marklogic.com/rest-api/resource/show-search-snipper>
>  namespace"}}
> 
> 
> 

So I tried moving the `show-search-snipper.xqy` file up 1 level (to test-app/rest-api/show-search-snipper.xqy`

Run the deployment
Deployment Works No errors
Hit the URL and receive the following

> 
> 
>  500 Internal Server Error
>  INTERNAL ERROR 
>  RESTAPI-INVALIDREQ: (err:FOER0000) Invalid request: reason: Extension
>  show-search does not exist. . See the MarkLogic server error log for
>  further detail. 
> 
> 
> 

Although I know the extension was created properly, since it worked fine before the introduction of the custom snip function. (with apply="raw")

Any thoughts how I can apply my custom snip function or what I am doing wrong in deployment? 

---

[![enter image description here](https://i.stack.imgur.com/P7uBK.png)](https://i.stack.imgur.com/P7uBK.png)