You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Gary Long <lo...@magillem.com> on 2010/07/08 16:11:50 UTC

error with xpath query

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(...)

Regards,

Gary




Re: error with xpath query

Posted by Gary Long <lo...@magillem.com>.
Le 08/07/2010 23:44, Alexander Klimetschek a écrit :
> 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
>
>    

Thank you for the advice :) I'll take a look at the wiki.

Regards,
Gary



Re: error with xpath query

Posted by Alexander Klimetschek <ak...@day.com>.
On Fri, Jul 9, 2010 at 10:47, Gary Long <lo...@magillem.com> wrote:
> In repository.xml I have two SearchIndex sections :
>
> the first one is inside a <workspace></workspace> section and has the
> following comments:
>
>> <!--
>>       Search index and the file system it uses.
>>       class: FQN of class implementing the QueryHandler interface
>>  -->
>
> The second one is outside the <workspace> section and has the following
> comment :
>
>> <!--
>>      Search index for content that is shared repository wide
>>      (/jcr:system tree, contains mainly versions)
>>  -->
>
> Do I have to add the parameter for indexingConfiguration in both sections ?

Unless you want to do the same searches inside jcr:system, ie. for
searching old versions of your content, no.

> Also, could the <workspace> section be the equivalent of the workspace.xml
> file?

For existing workspaces, you would have to change the workspace.xml.
And delete the <workspace>/index directory containg the lucene search
index to force a reindexing of your existing content.

The <Workspace/> element in the repository.xml is "just" a template
for new workspaces to be created.

Regards,
Alex

-- 
Alexander Klimetschek
alexander.klimetschek@day.com

Re: error with xpath query

Posted by Gary Long <lo...@magillem.com>.
Le 08/07/2010 23:44, Alexander Klimetschek a écrit :
> seems that it doesn't like the OR jcr:contains(...)
>    
> See http://wiki.apache.org/jackrabbit/IndexingConfiguration
>    

Hi again :)

I looked at the wiki documentation about indexingConfiguration. I 
understand that I have to add a parameter in the SearchIndex section, in 
repository.xml and workspace.xml.

In repository.xml I have two SearchIndex sections :

the first one is inside a <workspace></workspace> section and has the 
following comments:

> <!--
>        Search index and the file system it uses.
>        class: FQN of class implementing the QueryHandler interface
>  -->

The second one is outside the <workspace> section and has the following 
comment :

> <!--
>       Search index for content that is shared repository wide
>       (/jcr:system tree, contains mainly versions)
>  -->

Do I have to add the parameter for indexingConfiguration in both 
sections ? Also, could the <workspace> section be the equivalent of the 
workspace.xml file?

Regards,
Gary










Re: error with xpath query

Posted by Alexander Klimetschek <ak...@day.com>.
On Thu, Jul 8, 2010 at 16:11, Gary Long <lo...@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