You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Arunas F <ar...@gmail.com> on 2012/09/24 10:29:12 UTC

Aggregate index usage

Hello Jackrabbit community,
As Jackrabbit is very slow while using joins in queries, I want to use queries 
on a single node level. But the content on which I want to run queries is also 
two level below. So I'd like to take advantage of using aggregated indexes. As 
the jackrabbit wiki states I can  “... include the contents of descendant nodes 
into a single node ...”. But there is no documentation how could I use these 
aggregated indexes.

This is what I'm trying to do.

The content layout is:

[type:A] > nt:hierarchyNode
…
+ t:dataflow (type:C)
…

[type:B]
…

[type:C] > type:B
…
+ t:data (nt:unstructured)


Workspace indexing_configuration.xml:

<?xml version="1.0"?>
<!DOCTYPE configuration SYSTEM "http://jackrabbit.apache.org/dtd/indexing-
configuration-1.2.dtd">
<configuration
        xmlns:nt="http://www.jcp.org/jcr/nt/2.0"
        xmlns:t="http://......">

     <aggregate primaryType="t:A">
         <include>t:dataflow/t:data</include>
    </aggregate>
</configuration>

(I also tried other <include> variations like “*/*” and etc.) 


And my JCR_SLQ2 query:

SELECT * FROM [t:A] AS a WHERE a.[prop_from_data_node]= 'content'

(“prop_from_data_node” here is a property from a t:data node).


And the data in the workspace is:

/A(t:A)[node]/t:dataflow(type:C)[node]/t:data(nt:unstructured)
[node]/prop_from_data_node='content'(string)[property]

Running a query in this case returns 0 matches but I expect the node to be 
selected.
Can you explain what I'm doing wrong and how should I use index aggregates?

Thank you.

Best regards,
Arunas F


Re: Aggregate index usage

Posted by Alexander Klimetschek <ak...@adobe.com>.
On 24.09.2012, at 10:29, Arunas F <ar...@gmail.com> wrote:

> Workspace indexing_configuration.xml:
> 
> <?xml version="1.0"?>
> <!DOCTYPE configuration SYSTEM "http://jackrabbit.apache.org/dtd/indexing-
> configuration-1.2.dtd">
> <configuration
>        xmlns:nt="http://www.jcp.org/jcr/nt/2.0"
>        xmlns:t="http://......">
> 
>     <aggregate primaryType="t:A">
>         <include>t:dataflow/t:data</include>
>    </aggregate>
> </configuration>
> 
> SELECT * FROM [t:A] AS a WHERE a.[prop_from_data_node]= 'content'

The indexing configuration above is used for the full text index on the node scope, using jcr:contains (xpath) or CONTAINS (sql). E.g. in xpath:

//element(*, t:A)[jcr:contains(., "content")

would now return a result, as the properties in t:dataflow/t:data would also be put in the full-text index for the t:A nodes.

For your query using an equals you can already do that without any special index configuration as relative child property paths are possible:

//element(*, t:A)[@t:dataflow/t:data = "content"]

Don't know exactly how the sql/sql2 query for that looks like, but the concept (and actual index behavior) should be the same.

Cheers,
Alex