Hi all,

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 thought a workaround might be to do the first query, and then create another query where I OR all the uuid's and do a rep:excerpt in that query, but that doesn't produce anything usefull as well. ex: //*[(@jcr:uuid='ae1..' OR @jcr:uuid='..') and jcr:contains(., '*test*')]/rep:excerpt()


I can get a useable excerpt if I do the following query:
//*[jcr:contains(.,'*test*')]/(rep:excerpt(.))

I can't use this since this
a) doesn't allow me to search on just nodes who have the sling:resourceType
b) returns all the previously versions of the node.

Should I run my first query above, check if it has a content and then manually check if I can get an excerpt out of it?




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.



Thanks in advance,

Simo

Reply via email to