jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simon Gaeremynck <gaeremyn...@gmail.com>
Subject Re: Excerpts on search queries.
Date Fri, 27 Nov 2009 16:45:07 GMT
Thanks for the quick response!

I am now able to retrieve excerpts in one query for both content and  
According to http://issues.apache.org/jira/browse/JCR-920 it looks  
like it should work for properties (and it sort of does!)

The only thing I have to figure out is how to only show the  
highlighted bit and the content around it for that specific property.
This will probably need a custom excerpt provider.

Thanks for the help!


On 27 Nov 2009, at 16:03, Alexander Klimetschek wrote:

> On Sat, Nov 28, 2009 at 00:00, Simon Gaeremynck  
> <gaeremyncks@gmail.com> wrote:
>> I am trying to do a basic search query on the entire repository  
>> that returns
>> any node that has a  sling:resourceType property and that has a
>> property/content that matches a search string.
>> If there is a match I need to get all the properties of that node  
>> and an
>> excerpt of the matched string.
>> I have the following xpath query who returns the correct nodes:
>> //*[@sling:resourceType and (jcr:contains(jcr:content,'*test*') or
>> jcr:contains(.,'*test*'))]
>> This query gives me the parent of the jcr:content node and all the
>> properties on it, which is exactly what I want.
>> Now, I thought I could get the excerpts out of the results by  
>> appending
>> /rep:excerpt(.) like so:
>> //*[@sling:resourceType and (jcr:contains(jcr:content,'*test*') or
>> jcr:contains(.,'*test*'))]/rep:excerpt(.)
>> But this doesn't give my a usable excerpt.
> I guess the excerpt is only useful when done on the jcr:content node.
> So I think this query should do the trick:
> //*[@sling:resourceType and (jcr:contains(jcr:content,'test') or
> jcr:contains(.,'test'))]/rep:excerpt()
> and then you'd call the rep:excerpt() with the jcr:content as  
> parameter:
> Row row = ...
> Value excerpt = row.getValue("rep:excerpt(jcr:content)");
> In this case you could also switch between the excerpt from a
> jcr:content subnode or the node itself, depending on what exists.
> Note that I also changed "*test*" to "test" as that should give the
> same results. jcr:contains does a full text search, not an exact
> comparison, hence word stemming etc. all take place.
>> Another problem I'm facing with excerpts is when I try to get an  
>> excerpt out
>> of a property/jcr:content with no (or almost none) content around the
>> highlighted word/phrase.
>> It seems to fill up the space by taking other property values of  
>> the node.
> You can have a custom excerpt provider:
> http://wiki.apache.org/jackrabbit/ExcerptProvider
> Regards,
> Alex
> -- 
> Alexander Klimetschek
> alexander.klimetschek@day.com

View raw message