Hibernate Books

All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Embedded labelling, querying
PostPosted: Mon Jan 09, 2017 9:53 am 
Beginner
Beginner

Joined: Thu Jan 05, 2017 1:47 pm
Posts: 27
We're using OGM 5.1 Beta 1, with Neo4j at the moment.

I'm seeing that the labelling of embedded fields is different depending on whether the field is a single object or some sort of collection. The 'EMBEDDED' label is always created. And in the case of a collection a label is created as <entity_name>_<field_name>. When it's not a collection there is no additional label. We've annotated with @ElementCollection in the one case, and @Basic in the other.

This isn't causing us any grief at this point though, just an observation.

The other thing that could be causing us trouble is the query generation when a field within an embedded is constrained in the where clause. The cypher query always uses the EMBEDDED label despite there being a more specific label available (we're querying on a collection of embedded in this case).

This potentially causes trouble in two ways:
- the search within Neo4j is broader, as there are naturally many more rows labelled as EMBEDDED than with the more specific label
- it means we have to create an index on EMBEDDED.<field> rather than use the more specific label in order to ensure an index search - not sure, but potentially this creates more indexing work in Neo4j

Would it be possible to create and use more specific labels throughout?


Top
 Profile  
 
 Post subject: Re: Embedded labelling, querying
PostPosted: Tue Jan 10, 2017 11:39 am 
Hibernate Team
Hibernate Team

Joined: Fri Sep 09, 2011 3:18 am
Posts: 291
Hi,
thanks for letting us know.

I'll have a look. I just have a couple a question:

Quote:
The other thing that could be causing us trouble is the query generation when a field within an embedded is constrained in the where clause. The cypher query always uses the EMBEDDED label despite there being a more specific label available (we're querying on a collection of embedded in this case).


I think I understand what you mean but could you give me an example?

Quote:
Would it be possible to create and use more specific labels throughout?


What would you suggest?

Davide


Top
 Profile  
 
 Post subject: Re: Embedded labelling, querying
PostPosted: Wed Jan 11, 2017 8:54 am 
Beginner
Beginner

Joined: Thu Jan 05, 2017 1:47 pm
Posts: 27
Thanks.

The query is:

MATCH (ms:`FM_ALARM`) -[:sources]-> (`_ms1`:EMBEDDED), (ms:`FM_ALARM`) -[:sourceSystem]-> (`_ms2`:EMBEDDED) WHERE ((`_ms2`.scheme = {ssyssch}) AND (`_ms2`.namespace = {ssysns})) AND (((`_ms1`.scheme = {srcsch1}) AND (`_ms1`.namespace = {srcns1})) AND (`_ms1`.fdn = {srcfdn1})) RETURN ms

The alias _ms1 is for an embedded collection, which has it's own label - :fm_Alarm_sources (:<entity name>_<field name>). The field _ms1.fdn is the has an index. Ideally we'd only index :fm_Alarm_sources.fdn but since the query is referencing the :EMBEDDED label we're forced to create the index on :EMBEDDED.fdn, which is much wider in scope.

So the suggestion to use more specific labels amounts to a) adding specific labels to all embedded nodes (e.g. the alias _ms2 is for a non-collection embedded, and it doesn't seem to get a label on creation, so maybe use :fm_Alarm_sourceSystem), and b) using these labels in queries instead of :EMBEDDED to narrow the search scope, as well as narrowing the scope of any indexes one might need to create.


Top
 Profile  
 
 Post subject: Re: Embedded labelling, querying
PostPosted: Thu Jan 12, 2017 8:01 am 
Hibernate Team
Hibernate Team

Joined: Fri Sep 09, 2011 3:18 am
Posts: 291
Thanks I've created an issue to keep track of this proposal: https://hibernate.atlassian.net/browse/OGM-1231


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.