So far, I'm using this code to create a snippet based on a JSON document that I get from a MarkLogic search.
xquery version "1.0-ml";
module namespace searchlib="http://ihs.com/lib/searchlib";
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 searchlib:get-snippet($docc,$words) {
let $doc:= json:transform-from-json($docc)
let $squery := search:parse($words)
let $result := <result>{search:snippet($doc,$squery,
<transform-results apply="snippet" xmlns="http://marklogic.com/appservices/search">
<max-snippet-chars>255</max-snippet-chars>
</transform-results>)}</result>
return $result//search:match
};
When performing a search, I use:
cts.jsonPropertyValueQuery(fieldname, values,
['case-insensitive', 'diacritic-insensitive'])
Thus, the search works with diacritically sensitive and gives good results, but in search:snippetI can not pass the parameter diacritic-insensitive, as in cts.jsonPropertyValueQuery.
In the documentation I see this in the description
Parameters for determining grammar of a search and search management. See Description of $ options for a function search: search. Note that you cannot specify the apply attribute in the transform-results option with search: snippet; to use another fragmentation function, use search: search or search: allow instead.
But here he is:
search:snippet(
$result as node(),
$cts-query as schema-element(cts:query),
[$options as element(search:transform-results)?]
) as element(search:snippet)
, : snippet? ?
chΓ‘vez, , , , ,
-
highligh Chavez
-
highligh
!