I have requirement to count and highlight the matched terms, the below code counts OVER & LOAD as two different terms , whereas in near query(OVER NEAR/1[ordered] LOAD) this should be OVERLOAD(only one term which matched).
How can I achieve the matching terms as per near queries and not individual terms in near query?
let $bindings := map:new()
=> map:with("",
function($operator, $values, $options) {
cts:word-query($values, ('wildcarded', 'case-insensitive'), 1)
})
let $searchQuery := cts:parse($query,$bindings)
let $docs :=
for $each in cts:search(fn:doc(),$searchQuery)
let $matchCount := fn:count(fn:distinct-values(cts:walk($each, $searchQuery, $cts:text)))
return <count>{$matchCount}</count>
return $docs