jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexander Klimetschek <aklim...@day.com>
Subject Re: error with xpath query
Date Thu, 08 Jul 2010 21:44:47 GMT
On Thu, Jul 8, 2010 at 16:11, Gary Long <long@magillem.com> wrote:
> Hi there :)
>
> I wrote an xpath query to search content in jackrabbit but I can't make it
> work..
>
> /jcr:root/5512 LG-Ant//element(*,mnt:resource)[(jcr:contains(@jcr:text,
> 'test sample') OR jcr:contains(@jcr:name, 'test sample') OR
> jcr:contains(@jcr:owner, 'test sample') OR jcr:contains(@jcr:createdDate,
> 'test sample') OR jcr:contains(@jcr:lastModifiedDate, 'test sample') OR
> jcr:contains(@jcr:extension, 'test sample') OR jcr:contains(@jcr:data, 'test
> sample') OR jcr:contains(@jcr:title, 'test sample') OR
> jcr:contains(@jcr:from, 'test sample') OR jcr:contains(@jcr:to, 'test
> sample')) AND @jcr:type != 'null']
>
> I get the following error :
>
> javax.jcr.query.InvalidQueryException: Lexical error at line 1, column 105.
>  Encountered: "c" (99), after : ":" for statement: for $v in /jcr:root/5512
> LG-Ant//element(*,mnt:resource)[(jcr:contains(@jcr:text, 'test sample') OR
> jcr:contains ....
>
> It seems that it doesn't like the OR jcr:contains(...)

The "or" must be lowercase.

BTW, it looks like you might be able to simplify your queries by using
the indexing config. You would aggregate the interesting properties
only on the node level, eg. all your jcr:* props, and then just do a
jcr:contains(., 'test sample'). "." is the node scope. See
http://wiki.apache.org/jackrabbit/IndexingConfiguration

Also, I would not use the jcr: namespace for custom properties, it's
reserved for node types and properties from the specification. Might
become an issue when you switch to a future version of the JCR API and
"jcr:text" is now a built-in protected property, for example.

Regards,
Alex

-- 
Alexander Klimetschek
alexander.klimetschek@day.com

Mime
View raw message