Frage

I have got a problem with clusters in orient db. So I would like to be sure that my understanding of clusters is correct and then it would be great if you could help me with my problem.

My understanding of Clusters

first I would like to ensure that I understand the concept of clusters correctly: For me a cluster is a subset of the data, one cluster can contain different classes and a single class can be contained in different clusters, is that correct ?

So for example I have the Data:

{"name": "john", "sports": "tennis", "gender": "male", "@class": "assistant"}
{"name": "susan", "sports": "hockey", "gender": "female", "@class": "assistant"}
{"name": "peter", "sports": "hockey", "gender": "male", "@class": "trainee"}
{"name": "mary", "sports": "tennis", "gender": "female", "@class": "trainee"}

and then I can have clusters like that:

cluster:Male {john, peter}
cluster:Tennis {john, mary}

Is this understanding of clusters in OrientDB correct?

My Problem with Clusters

When inserting new Data to my database I want to add the data to a specific cluster. My Data is in json format. The cluster already exists. But after inserting with the following command the cluster is still empty. This occurs by using the java API as well as using the web interface.

INSERT INTO cluster:Test CONTENT {"name": "john", "@class": "assistant"}

The data itself is saved, when requesting:

SELECT FROM assistant

I do find the entry but the entry is not in the cluster:Test. What am I doing wrong?


Edit 2014/03/26

My Usecase

I actually save Tweets in my database. I am searching Twitter by given keywords. My class model looks like:

  • TwitterTweet
  • TwitterUser
  • Hashtag

(with a TwitterBaseClass above Tweet and User) and I have edges like that:

TwitterTweet --originalTweet--> TwitterTweet
TwitterTweet --postedBy--> TwitterUser
TwitterTweet --hasHashtag--> Hashtag

And I thought best practice to do efficient requests was to create a cluster for every keyword. So for example when I have the keywords "shark" and "dog" I get tweets for sharks and dogs and they are all stored in the same graph in different clusters.


Your help is greatly appreciated, thanks in advance
Ludwig

orient-db v. 1.7-rc1

War es hilfreich?

Lösung

In the next release 2.0 you cannot associate multiple clusters to a class, so in order to stay compatible with future releases, it's better to use class inheritance to split your records on multiple clusters.

Edit 2014-10-08:

This is not true anymore, with 2.0 you cannot store a record in any cluster, but it should be declared that host records of X class. So classes can have multiple clusters. We use this feature to manage distributed.

Andere Tipps

You should add the cluster "Test" to the class assistant via API or via SQL:

alter class assistant addcluster test
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top