jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alexander Klimetschek" <aklim...@day.com>
Subject Re: Query for objects with reduced set of attributes
Date Wed, 16 Jul 2008 00:27:36 GMT
On Wed, Jul 16, 2008 at 2:11 AM, MARTINEZ Antonio
<Antonio.Martinez@alcatel-lucent.com> wrote:
> I do some processing with result to send it to GUI.
> My problem was that most of the cases I'm not interested in all
> attributes (but in some others I am).
> Currently I just remove the properties that I'm not interested in, from
> each result node.

By calling property.remove() / setProperty(name, null)? That is ok,
but not very efficient, since it puts all modified nodes into the
transient space (additional memory used). Why not just ignore the
properties you don't need?

Otherwise, if you modify them anyway for "post-processing" (without a
session.save()), it should not harm.

> I was looking for the same thing inside JackRabbit, thinking that maybe
> even the query time would improve.

No, even if such a feature would be present, it wouldn't improve query
time. The nodes you get are fetched the same as with a
getNode(relPath) call, since you want the newest version. In a
non-remote environment, filtering would harm performance here (with a
remote protocol it could theoretically save bandwidth).

> But since it is not possible, no problem. I'll keep doing the same.
>
> Thank-you!
> Antonio
>
> -----Original Message-----
> From: Alexander Klimetschek [mailto:aklimets@day.com]
> Sent: Tuesday, July 15, 2008 4:27 PM
> To: users@jackrabbit.apache.org
> Subject: Re: Query for objects with reduced set of attributes
>
> Are you exporting the results directly as XML? Filtering down to
> properties is not possible with queries in JCR, because they are more
> tied to the JCR model than to XML views. In JCR queries, you will always
> get nodes as result (albeit you can access the properties directly with
> QueryResult.getRows(). For XML export, you will have to do any
> additional output filtering yourself.
>
> Regards,
> Alex
>
> On Wed, Jul 16, 2008 at 1:14 AM, MARTINEZ Antonio
> <Antonio.Martinez@alcatel-lucent.com> wrote:
>> Hello Alex,
>>
>> Thanks for the reply.
>>
>> Query //root/obj_level_1/obj_level_2[@attr1 and not(@attr2) and
>> not(@attr3)] performs filtering.
>> In my case I do not want to filter.
>> Let me put an example. I have 100 obj_level_2, each one of them
>> containing attr1, attr2 and attr3.
>> I want to formulate a query to get all 100 obj_level_2, but I only
>> want to get property attr1 for each one of them.
>> Otherwise, I need to do the query //root/obj_level_1/obj_level_2 and
>> remove attr2 and attr3 from the result myself.
>> Maybe it is not possible.
>>
>> Thanks,
>> Antonio
>>
>>
>> -----Original Message-----
>> From: Alexander Klimetschek [mailto:aklimets@day.com]
>> Sent: Tuesday, July 15, 2008 3:48 PM
>> To: users@jackrabbit.apache.org
>> Subject: Re: Query for objects with reduced set of attributes
>>
>> You need predicates defined in square brackets. Simply stating the
>> property checks for its existence:
>>
>> //root/obj_level_1/obj_level_2[@attr1 and not(@attr2) and not(@attr3)]
>>
>> This query would find all nodes with a property "attr1", but without a
>
>> property "attr2" and "attr3".
>>
>> Regards,
>> Alex
>>
>> On Wed, Jul 16, 2008 at 12:06 AM, MARTINEZ Antonio
>> <Antonio.Martinez@alcatel-lucent.com> wrote:
>>> Hello,
>>>
>>> If I do query
>>>
>>>  //root/obj_level_1/obj_level_2
>>>
>>> I get all obj_level_2 objects, these containing all its attributes
>>> (say attr1, attr2, attr3, ...)
>>>
>>> Is it possible to formulate a query to get all obj_level_2 objects
>>> with a reduced # of attributes per object?  I tried
>>>
>>>   //root/obj_level_1/obj_level_2/@attr1  , trying to get all
>>> obj_level_2 objects with only attr1, but I get the same result as
>>> with
>>
>>> the previous string
>>>
>>> Thanks,
>>> Antonio
>>>
>>
>>
>>
>> --
>> Alexander Klimetschek
>> alexander.klimetschek@day.com
>>
>
>
>
> --
> Alexander Klimetschek
> alexander.klimetschek@day.com
>



-- 
Alexander Klimetschek
alexander.klimetschek@day.com

Mime
View raw message