The below per-match-tokens  does not support the words count from
surrounding child, siblings and parents nodes, is anything missing? Please
advise.

$surroundingWords =20

<transform-results apply="snippet">
  {
 if($surroundingWords)
 then
<per-match-tokens>{xs:int($surroundingWords/text())*2}</per-match-tokens>
 else <per-match-tokens>20</per-match-tokens>
  }
    <preferred-elements>
      <element name="p" ns="http://www.w3.org/1999/xhtml"/>
      <element name="Text"/>
    </preferred-elements>
 </transform-results>

Regards,
Dinesh


-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Michael
Blakeley
Sent: Sunday, 10 August, 2014 7:46 AM
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] Search Snippet

That sounds like the `per-match-tokens` option for the built-in snippet
function: https://docs.marklogic.com/guide/search-dev/query-options#id_36346

-- Mike

On 9 Aug 2014, at 09:18 , Dinesh <[email protected]> wrote:

> Hi,
> Does anyone have an example of using custom code to customize snippet to
get surrounding words for search hits.
> The requirement, users select the number of surrounding words, MarkLogic
to return number of surrounding words for the snippet, the surrounding words
from text of any child/parent/preceding/following elements.
> Thanks.
> Regards,
> Dinesh
> _______________________________________________
> General mailing list
> [email protected]
> http://developer.marklogic.com/mailman/listinfo/general

_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to