Hi Christian,

thank you.

That works great.

Johannes

Am 13.08.2018 um 14:05 schrieb Christian Grün:
Hi Johannes,

Try this:

  <result>{
    let $search := 'search'
    for $match in //*[text() contains text { $search }]
    let $match_parent := $match/..
    return <match>{
ft:mark($match_parent[.//text() contains text { $search }])
    }</match>
  }</result>

Best,
Christian



On Mon, Aug 13, 2018 at 7:09 AM Johannes Bauer <johannes.ba...@tanner.de <mailto:johannes.ba...@tanner.de>> wrote:

    Hello,

    I have a question regarding the usage of the ft:mark() function.

    Database content:

    <root>
         <div>
             <p>Some text <b>text search text</b> some more text</p>
         </div>
    </root>

    XQuery:

    <result>
    {
    let $search := 'search'
    for $match at $pos in //*[text() contains text {$search}]
    let $match_parent := $match/..
    return
    <match>{ft:mark($match_parent//*[text() contains text
    {$search}])}</match>
    }
    </result>

    Current result:

    <result>
         <match>
             <b>text <mark>search</mark> text</b>
         </match>
    </result>

    What I would like to achieve is the following output:

    <result>
         <match>
             <p>Some text <b>text <mark>search</mark> text</b> some more
    text</p>
         </match>
    </result>

    ft:mark() returns the found element node with the marked content
    inside.

    Is it possible to get the whole paragraph content (the parent
    element of
    the found element) with the marker element inside?

    Any help would be much appreciated.

    Best regards
    Johannes



Reply via email to