Quantcast

highligh element value of a matched attribute

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

highligh element value of a matched attribute

Alfredo Cosco
Hello,
i'm facing the same problem described in this post: 

I'm using exist 2.2 stable

I have a document like this:

<doc>
lorem ipsum <name id="jd">Jon doe</name> dolor sit amet.
</doc>

So i set up a lucene index on name/@id in collection.xconf:

<text qname="@id"/>

Then I made a function with query that matches @id:

declare function app:search-by-names($node as node(), $model as map(*), $query as xs:string?) {
        let $hits :=
            for $hit in collection($config:data-root)//doc//*[ft:query(name/@id, $query)]
            order by ft:score($hit) descending
                return 
                    $hit
        return
            map {
                "hits" := $hits,
                "query" := $queryExpr
            }

};


And a function to show hits in html template:

declare 
    %templates:wrap
function app:show-hits($node as node()*, $model as map(*)) {
    let $queryString := request:get-parameter("query", ())
    for $hit at $p in $model("hits")
                                                                                                                                                                                                          
    let $kwic:= kwic:summarize($hit, <config width="40" table="no" link=""/>) 
   
    return
       $kwic
       
};

The query works well because if I:
    
    return
        $hits

the results appears, but I can't figure how to highlight the value of the tag matched by the @id.

Has anyone found a solution?

Thanks
Alfredo


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: highligh element value of a matched attribute

Joe Wicentowski
Hi Alfredo,

Some related features are in eXist 3.0 develop:


To try this out, grab the latest nightly build or build your own from source - until the forthcoming 3.0 release.

Joe

Sent from my iPad




On Fri, Feb 3, 2017 at 11:33 AM -0500, "Alfredo Cosco" <[hidden email]> wrote:

Hello,
i'm facing the same problem described in this post: 

I'm using exist 2.2 stable

I have a document like this:

<doc>
lorem ipsum <name id="jd">Jon doe</name> dolor sit amet.
</doc>

So i set up a lucene index on name/@id in collection.xconf:

<text qname="@id"/>

Then I made a function with query that matches @id:

declare function app:search-by-names($node as node(), $model as map(*), $query as xs:string?) {
        let $hits :=
            for $hit in collection($config:data-root)//doc//*[ft:query(name/@id, $query)]
            order by ft:score($hit) descending
                return 
                    $hit
        return
            map {
                "hits" := $hits,
                "query" := $queryExpr
            }

};


And a function to show hits in html template:

declare 
    %templates:wrap
function app:show-hits($node as node()*, $model as map(*)) {
    let $queryString := request:get-parameter("query", ())
    for $hit at $p in $model("hits")
                                                                                                                                                                                                          
    let $kwic:= kwic:summarize($hit, <config width="40" table="no" link=""/>) 
   
    return
       $kwic
       
};

The query works well because if I:
    
    return
        $hits

the results appears, but I can't figure how to highlight the value of the tag matched by the @id.

Has anyone found a solution?

Thanks
Alfredo


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open
Loading...