Hi Colin,
I've put together a quick test of this and it does indeed return Bob even 
if he did not apply the Red tag to Resource1.
Attached are 2 files: 
1) I run test_db_schema.sql as an argument to the console.sh script to 
create the database and schema.
2) I then start the console, connect to the database then copy and paste 
the contents of test_db_data.sql into the console after issuing the 'script 
sql' command. I don't know why but I couldn't use the let statement from 
within a file.

I have included your query at the end of the script and the Bob record is 
returned even if he didn't tag Resource1 with Red.
-Phill

On Wednesday, March 18, 2015 at 4:33:47 PM UTC+1, Colin wrote:
>
> No, because the inner most select specifies "Resource1" as a starting 
> point.
>
> -Colin
>
> Orient Technologies
>
> The Company behind OrientDB
>
> On Wednesday, March 18, 2015 at 9:28:22 AM UTC-5, Phil wrote:
>>
>> With the data in my diagram would this not also return Bob if he applied 
>> the red tag only to Resource2 and not Resource1 ?
>> He tagged Resource1 only with blue.
>>
>>
>> On Wednesday, March 18, 2015 at 3:11:12 PM UTC+1, Colin wrote:
>>>
>>> Hi Phil,
>>>
>>> I may just be missing something, but here's a simple example of what I'm 
>>> thinking.
>>>
>>> select from (select expand(in("AppliedTag")) from (select 
>>> expand(out("HasTag")) from Resource where Id="Resource1") where Id="Red") 
>>> where Name = "Bob"
>>>
>>> This will return Bob after selecting Resource1 and then selecting its 
>>> associated tags, filtering on the Red Id.
>>>
>>> Does that make sense?
>>>
>>> -Colin
>>>
>>> Orient Technologies
>>>
>>> The Company behind OrientDB
>>>
>>

-- 

--- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.
begin
let red = insert into Tag (value) values ('Red')
let blue = insert into Tag (value) values ('Blue')
let bob = insert into Person (firstName) values ('Bob')
let alice = insert into Person (firstName) values ('Alice')
let r1 = insert into Resource (title) values ('Resource1')
let r2 = insert into Resource (title) values ('Resource2')

-- Bob tags Resource1 Blue
create edge Tagged from $bob to $r1
-- Bob applied Blue
create edge AppliedTag from $bob to $blue
-- Resource1 has Blue tag
create edge HasTag from $r1 to $blue

-- Bob tagged Resource2 Red
create edge Tagged from $bob to $r2
create edge AppliedTag from $bob to $red
-- Resource2 has Red tag
create edge HasTag from $r2 to $red

-- Alice tags both resources Red
create edge Tagged from $alice to $r1
create edge Tagged from $alice to $r2

create edge AppliedTag from $alice to $red
create edge AppliedTag from $alice to $blue
-- Resource1 has Red tag
create edge HasTag from $r1 to $red
-- Resource2 has Red tag
create edge HasTag from $r2 to $red

let q = select from (select expand(in("AppliedTag")) from (select expand(out("HasTag")) from Resource where title="Resource1") where value="Red") where firstName = "Bob";
commit
return $q
end
create database remote:localhost/test_db root orient plocal;
create class Person extends V;
create property Person.firstName string;
create class Tag extends V;
create property Tag.value string;
create class Resource extends V;
create property Resource.title string;
create class Tagged extends E;
create class AppliedTag extends E;
create class HasTag extends E;

Reply via email to