[orientdb] Re: How to get records that are linked to each of given vertices

2015-03-12 Thread Red-0ne
Yes, tags types and number are chosen by user and cannot be predicted. I 
understand that this could be inefficient, but shouldn't we have a (native) 
way (a *CONTAINSEACH* *[ ]* keyword, or something alike) to get vertices 
connected to each vertex of a given set? Isn't this a relatively frequent 
use case?

Anyway, thank you for the directions provided.

On Monday, 9 March 2015 15:59:16 UTC+1, Colin wrote:
>
> If the name properties are random and not tied to a specific group or type 
> of user, then there's no simple way to achieve what you want since you 
> can't predict the type of name or how many will be queried.
>
> This is not an efficient query if Data contains millions of edges.
>
> It would be easier to build using the Blueprints Graph API.
>
> -Colin
>
> On Friday, March 6, 2015 at 3:39:12 PM UTC-6, Red-0ne wrote:
>>
>> Ok here is an example:
>>
>> CREATE DATABASE remote:localhost/testdb root root memory
>>
>> CREATE CLASS Data EXTENDS V;
>> CREATE PROPERTY Data.id INTEGER;
>>
>> CREATE CLASS Tag EXTENDS V;
>> CREATE PROPERTY Tag.name STRING;
>>
>> CREATE CLASS hasTag EXTENDS E;
>>
>> CREATE VERTEX Data SET id = 1;
>> CREATE VERTEX Data SET id = 2;
>> CREATE VERTEX Tag SET name = 'A';
>> CREATE VERTEX Tag SET name = 'B';
>>
>> #Link to both A and B
>> CREATE EDGE hasTag FROM (SELECT FROM Data WHERE id = 1) TO (SELECT FROM 
>> Tag WHERE name = 'A');
>> CREATE EDGE hasTag FROM (SELECT FROM Data WHERE id = 1) TO (SELECT FROM 
>> Tag WHERE name = 'B');
>>
>> #Link only to A
>> CREATE EDGE hasTag FROM (SELECT FROM Data WHERE id = 2) TO (SELECT FROM 
>> Tag WHERE name = 'A');
>>
>> #Get Data that is linked to both (Tag vertices having name) A and B, 
>> should get Data with id = 1
>> SELECT FROM Data WHERE out('hasTag') CONTAINS (name = 'A') AND out(
>> 'hasTag') CONTAINS (name = 'B');
>>
>> In my app Tag vertices (having name 'A' and 'B') are provided by the 
>> client app and could be more than 2 Tags, that's why I'm trying to avoid 
>> the *CONTAINS ... AND CONTAINS* ... part, when building my query.
>>
>> Thank you for your patience.
>>
>>>
>>>>>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to orient-database+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[orientdb] Re: Pass object to OrientDB function

2015-03-07 Thread Red-0ne
You can do it as per function documentation 

 
but you have to *url encode* your serialized object.

In order to pass:
{"x":1,"y":2}

you have to send:
http://localhost:2480/function/testdb/testfn/%7B%22x%22%3A1%2C%22y%22%3A2%7D

On Saturday, 7 March 2015 13:21:34 UTC+1, Artem Nikiforov wrote:
>
> I want to pass json serialized object to stored function in call made via 
> REST interface.
> [How ]can it be done?
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to orient-database+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[orientdb] Re: How to get records that are linked to each of given vertices

2015-03-06 Thread Red-0ne
Ok here is an example:

CREATE DATABASE remote:localhost/testdb root root memory

CREATE CLASS Data EXTENDS V;
CREATE PROPERTY Data.id INTEGER;

CREATE CLASS Tag EXTENDS V;
CREATE PROPERTY Tag.name STRING;

CREATE CLASS hasTag EXTENDS E;

CREATE VERTEX Data SET id = 1;
CREATE VERTEX Data SET id = 2;
CREATE VERTEX Tag SET name = 'A';
CREATE VERTEX Tag SET name = 'B';

#Link to both A and B
CREATE EDGE hasTag FROM (SELECT FROM Data WHERE id = 1) TO (SELECT FROM Tag 
WHERE name = 'A');
CREATE EDGE hasTag FROM (SELECT FROM Data WHERE id = 1) TO (SELECT FROM Tag 
WHERE name = 'B');

#Link only to A
CREATE EDGE hasTag FROM (SELECT FROM Data WHERE id = 2) TO (SELECT FROM Tag 
WHERE name = 'A');

#Get Data that is linked to both (Tag vertices having name) A and B, should 
get Data with id = 1
SELECT FROM Data WHERE out('hasTag') CONTAINS (name = 'A') AND out('hasTag') 
CONTAINS (name = 'B');

In my app Tag vertices (having name 'A' and 'B') are provided by the client 
app and could be more than 2 Tags, that's why I'm trying to avoid the *CONTAINS 
... AND CONTAINS* ... part, when building my query.

Thank you for your patience.

On Friday, 6 March 2015 05:36:04 UTC+1, Colin wrote:
>
> If A, B, C are all vertices and each represents a different type of class, 
> then you could could create a different edge type for each one.
>
> Are A, B, C all unique types that derive from a common base?
>
> Maybe if you can give a more real-world example with the needed result, we 
> can figure it out.
>
> Sorry, if I'm being dense.  :-)
>
> -Colin
>
> On Thursday, March 5, 2015 at 4:05:44 PM UTC-6, Red-0ne wrote:
>>
>> Sorry for being misleading. A, B, C are vertices of themselves and 
>> created through "CREATE VERTEX" command. I just tried to represent them by 
>> their @rids in the above query.
>>
>> On Thursday, 5 March 2015 16:51:14 UTC+1, Colin wrote:
>>>
>>> I think I'm a little puzzled why/how A, B are @rids and vertices but 
>>> not.  :-)
>>>
>>> Are A, B, C always unique 'tags' as in properties of vertices that 
>>> denote some kind of type?  Or, are A, B, C types of vertices themselves?
>>>
>>>
>>> On Thursday, March 5, 2015 at 5:37:37 AM UTC-6, Red-0ne wrote:
>>>>
>>>> Actually vertices A, B, C... are kind of *tags*, and Vi are *data*. My 
>>>> use case is as simple as: "get data that matches *all* given tags".
>>>>
>>>> On Tuesday, 3 March 2015 19:19:58 UTC+1, Colin wrote:
>>>>>
>>>>>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to orient-database+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[orientdb] Re: How to get records that are linked to each of given vertices

2015-03-05 Thread Red-0ne
Sorry for being misleading. A, B, C are vertices of themselves and created 
through "CREATE VERTEX" command. I just tried to represent them by their 
@rids in the above query.

On Thursday, 5 March 2015 16:51:14 UTC+1, Colin wrote:
>
> I think I'm a little puzzled why/how A, B are @rids and vertices but not.  
> :-)
>
> Are A, B, C always unique 'tags' as in properties of vertices that denote 
> some kind of type?  Or, are A, B, C types of vertices themselves?
>
>
> On Thursday, March 5, 2015 at 5:37:37 AM UTC-6, Red-0ne wrote:
>>
>> Actually vertices A, B, C... are kind of *tags*, and Vi are *data*. My 
>> use case is as simple as: "get data that matches *all* given tags".
>>
>> On Tuesday, 3 March 2015 19:19:58 UTC+1, Colin wrote:
>>>
>>>
>>>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to orient-database+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[orientdb] Re: How to get records that are linked to each of given vertices

2015-03-05 Thread Red-0ne
Actually vertices A, B, C... are kind of *tags*, and Vi are *data*. My use 
case is as simple as: "get data that matches *all* given tags".

On Tuesday, 3 March 2015 19:19:58 UTC+1, Colin wrote:
>
> I don't know if this will help, but I usually model my edges so they they 
> reflect a specific type (or sub-type).
>
> If you're needing to query a result for one or more specific RIDs, I'd 
> create an index.
>
> -Colin
>
> Orient Technologies
>
> The Company behind OrientDB
>
>
> On Tuesday, March 3, 2015 at 9:53:34 AM UTC-6, Red-0ne wrote:
>>
>> I have a database where vertices *Vi* are linked to vertex *A* or *B* or 
>> *both* via edge *'hasAspect*'.
>> I want to get all the vertices that are linked to both *A* and *B*. The 
>> only way I found is (having A and B being @rids):
>>
>> SELECT FROM V WHERE out('hasAspect') CONTAINS (@rid = A) AND out(
>> 'hasAspect') CONTAINS (@rid = B)
>>
>> Is there a more elegant way to achieve the same result? Knowing that it 
>> could easily become ugly if I have to filter for more than only A and B? 
>> (C, D, E, F...)
>>
>> Thank you
>>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to orient-database+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[orientdb] How to get records that are linked to each of given vertices

2015-03-03 Thread Red-0ne
I have a database where vertices *Vi* are linked to vertex *A* or *B* or 
*both* via edge *'hasAspect*'.
I want to get all the vertices that are linked to both *A* and *B*. The 
only way I found is (having A and B being @rids):

SELECT FROM V WHERE out('hasAspect') CONTAINS (@rid = A) AND out('hasAspect'
) CONTAINS (@rid = B)

Is there a more elegant way to achieve the same result? Knowing that it 
could easily become ugly if I have to filter for more than only A and B? 
(C, D, E, F...)

Thank you

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to orient-database+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[orientdb] Batch mode: return a map of expanded records

2015-02-23 Thread Red-0ne
Hello,
Trying to get more than one record using batch mode:

BEGIN
LET file = CREATE VERTEX File SET path = '/tmp/some_file'
CREATE EDGE ownsFile FROM #16:0 TO $file
LET user = UPDATE #16:0 INCREMENT files = 1 RETURN AFTER
COMMIT RETRY 100
RETURN { user: $user, file: $file }

Everything is ok except that the returned map contains rids instead of 
expanded record. I suppose this is the intended behaviour.

So is there a way to get the expanded records into the returned map instead 
of rid?

Thank you.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to orient-database+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[orientdb] Re: Error updating OUser record when OIdentity extends V

2015-01-27 Thread Red-0ne
Actually this happens because the *member* role is not visible to the user 
(user cannot read *member* role due to ORestricted inheritance).
So the real question is: How to have a class that inherits both *V* and 
*ORole* having *V* extending *ORestricted*.

On Tuesday, 27 January 2015 13:20:05 UTC+1, Red-0ne wrote:
>
> Hello,
> We are trying to have a *Member* class that extends *OUser*. This *Member 
> *class should also extends *V*. Additionally, *V* have to extend 
> *ORestricted*. A *member* ORole is needed to.
>
> For that we've done the following (using console.sh):
>
> DROP DATABASE remote:localhost/sometestdb root root
> CREATE DATABASE remote:localhost/sometestdb root root plocal;
>
> ALTER CLASS V SUPERCLASS ORestricted;
> ALTER CLASS OIdentity SUPERCLASS V;
>
> CREATE CLASS Member EXTENDS OUser;
>
> #We create *member* role as a vertex (ORole extends OIdentity which 
> extends V)
> #This is the problematic query...
> CREATE VERTEX ORole SET name = 'member', mode = 0;
>
> #Have minimum resource permissions
> UPDATE ORole PUT rules = "database.class.Member", 14 WHERE name = 'member'
> ;
> UPDATE ORole PUT rules = "database.cluster.Member", 14 WHERE name = 
> 'member';
>
> UPDATE ORole PUT rules = "database.class.OFunction", 2 WHERE name = 
> 'member';
> UPDATE ORole PUT rules = "database.cluster.OFunction", 2 WHERE name = 
> 'member';
>
> UPDATE ORole PUT rules = "database.class.OSchedule", 2 WHERE name = 
> 'member';
> UPDATE ORole PUT rules = "database.cluster.OSchedule", 2 WHERE name = 
> 'member';
>
> UPDATE ORole PUT rules = "database.cluster.OUser", 2 WHERE name = 'member'
> ;
> UPDATE ORole PUT rules = "database.cluster.ORole", 2 WHERE name = 'member'
> ;
>
> UPDATE ORole PUT rules = "database.cluster", 15 WHERE name = 'member';
> UPDATE ORole PUT rules = "database.cluster.internal", 2 WHERE name = 
> 'member';
> UPDATE ORole PUT rules = "database.hook.record", 15 WHERE name = 'member';
>
> #Create member with a member role
> CREATE VERTEX Member SET name = 'test', password = 'test', status = 
> 'ACTIVE', roles = (SELECT FROM ORole WHERE name = 'member');
>
> #Actually classes that extend OUser do not get their password hashed, so 
> we hash it manually
> UPDATE Member SET password = format("{SHA-256}%s", password.hash('SHA-256'
> )) WHERE name = 'test';
>
> #Allow a member to manipulate himself
> UPDATE Member ADD _allow = $rid LET $rid = @rid WHERE name = 'test';
>
> #Reconnect using current member (test user)
> DISCONNECT;
> CONNECT remote:localhost/sometestdb test test;
>
> #Trying to update member
> UPDATE Member SET name = 'changed' WHERE name = 'test';
>
> Every thing is working fine until we try to update *Member*, so we get 
> this error:
> Error: com.orientechnologies.orient.core.exception.
> OCommandExecutionException: Error on execution of command: sql.select from 
> Member WHERE  name = 'test'
>
> Error: com.orientechnologies.orient.core.exception.OValidationException: 
> The field 'OUser.roles' has been declared as LINKSET but contains a null 
> record (probably a deleted record?)
>
> But when creating the *member* ORole before extending OIdentity with V
> ...
> ALTER CLASS V SUPERCLASS ORestricted;
> #Create *member* role before extending OIdentity
> #We use INSERT instead of CREATE VERTEX as ORole is not a vertex yet
> INSERT INTO ORole SET name = 'member', mode = 0;
>
> ALTER CLASS OIdentity SUPERCLASS V;
> ...
>
> Everything is working fine.
>
> Are we doing thomething wrong?
> Is this some kind of bug?
> What is the best way to achieve our previously cited constraints?
>
> Thank you
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to orient-database+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[orientdb] Error updating OUser record when OIdentity extends V

2015-01-27 Thread Red-0ne
Hello,
We are trying to have a *Member* class that extends *OUser*. This *Member 
*class 
should also extends *V*. Additionally, *V* have to extend *ORestricted*. A 
*member* ORole is needed to.

For that we've done the following (using console.sh):

DROP DATABASE remote:localhost/sometestdb root root
CREATE DATABASE remote:localhost/sometestdb root root plocal;

ALTER CLASS V SUPERCLASS ORestricted;
ALTER CLASS OIdentity SUPERCLASS V;

CREATE CLASS Member EXTENDS OUser;

#We create *member* role as a vertex (ORole extends OIdentity which extends 
V)
#This is the problematic query...
CREATE VERTEX ORole SET name = 'member', mode = 0;

#Have minimum resource permissions
UPDATE ORole PUT rules = "database.class.Member", 14 WHERE name = 'member';
UPDATE ORole PUT rules = "database.cluster.Member", 14 WHERE name = 'member'
;

UPDATE ORole PUT rules = "database.class.OFunction", 2 WHERE name = 'member'
;
UPDATE ORole PUT rules = "database.cluster.OFunction", 2 WHERE name = 
'member';

UPDATE ORole PUT rules = "database.class.OSchedule", 2 WHERE name = 'member'
;
UPDATE ORole PUT rules = "database.cluster.OSchedule", 2 WHERE name = 
'member';

UPDATE ORole PUT rules = "database.cluster.OUser", 2 WHERE name = 'member';
UPDATE ORole PUT rules = "database.cluster.ORole", 2 WHERE name = 'member';

UPDATE ORole PUT rules = "database.cluster", 15 WHERE name = 'member';
UPDATE ORole PUT rules = "database.cluster.internal", 2 WHERE name = 
'member';
UPDATE ORole PUT rules = "database.hook.record", 15 WHERE name = 'member';

#Create member with a member role
CREATE VERTEX Member SET name = 'test', password = 'test', status = 'ACTIVE'
, roles = (SELECT FROM ORole WHERE name = 'member');

#Actually classes that extend OUser do not get their password hashed, so we 
hash it manually
UPDATE Member SET password = format("{SHA-256}%s", password.hash('SHA-256')) 
WHERE name = 'test';

#Allow a member to manipulate himself
UPDATE Member ADD _allow = $rid LET $rid = @rid WHERE name = 'test';

#Reconnect using current member (test user)
DISCONNECT;
CONNECT remote:localhost/sometestdb test test;

#Trying to update member
UPDATE Member SET name = 'changed' WHERE name = 'test';

Every thing is working fine until we try to update *Member*, so we get this 
error:
Error: com.orientechnologies.orient.core.exception.
OCommandExecutionException: Error on execution of command: sql.select from 
Member WHERE  name = 'test'

Error: com.orientechnologies.orient.core.exception.OValidationException: The 
field 'OUser.roles' has been declared as LINKSET but contains a null record 
(probably a deleted record?)

But when creating the *member* ORole before extending OIdentity with V
...
ALTER CLASS V SUPERCLASS ORestricted;
#Create *member* role before extending OIdentity
#We use INSERT instead of CREATE VERTEX as ORole is not a vertex yet
INSERT INTO ORole SET name = 'member', mode = 0;

ALTER CLASS OIdentity SUPERCLASS V;
...

Everything is working fine.

Are we doing thomething wrong?
Is this some kind of bug?
What is the best way to achieve our previously cited constraints?

Thank you

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to orient-database+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[orientdb] Re: Remove embeddedset item by reference?

2014-04-18 Thread Red-0ne
I can't find the issue about this problem and it doesn't seem to be 
resolved. Any update on that ?

On Monday, March 24, 2014 10:33:56 PM UTC+1, Jonathan Rosen wrote:
>
> let's say i have an embedded set field "people" in record #5:12:
>
> ["bob", "jon"]
>
> this doesnt seem to work:
> update #5:12 remove people[0]
>
> this does work however: update #5:12 remove "bob"
>
> is there any way to remove items by reference, as in case #1?
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to orient-database+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.