Creating indexes on embedded document properties

35 views
Skip to first unread message

Rodrigo Abt

unread,
Apr 3, 2016, 5:13:15 PM4/3/16
to OrientDB
Hi guys,

I'm using OrientDB 2.1.14 with OS X El Capitan. I've been developing a complex model which involves saving lists of documents inside properties. So I have a vertex class named "Student" with a property called "profile" of type EmbeddedList. Here is sample of data saved in that property:

select profile from Student limit 1

[
   
{"@type":"d","@version":0,"folder":{"id":27096,"active":"yed"},
   
{"@type":"d","@version":0,"folder":{"id":32672,"active":"no"}
]


I have no problems querying the data:

select from Student where profile contains (folder.id=27096)

But it's slow. I was planning to create an index on "folder.id". So I tried lots of alternatives, but only this one actually created an index:

CREATE INDEX idx ON Student (profile.folder.id) notunique string

 However a query on that index:

select from index:idx limit 2

gives:


{
    "result": [
        {
            "@type": "d",
            "@version": 0,
            "key": "[111]",
            "rid": "#22:2871",
            "@fieldTypes": "rid=x"
        },
                 {
            "@type": "d",
            "@version": 0,
            "key": "[27096, 32672]",
            "rid": "#22:2888",
            "@fieldTypes": "rid=x"
        }
    ],
    "notification": "Query executed in 0.025 sec. Returned 2 record(s)"
}

where "key" returns a list evaluated as a string. If I try:

select from index:idx where key = 32672

it gives nothing, but if I use:

select from index:idx where key = '[27096, 32672]'
 
it works. What am I doing wrong?. I need to query each id independently.

Please help. Thanks.

Regards,
Rodrigo



scott molinari

unread,
Apr 4, 2016, 2:14:34 AM4/4/16
to OrientDB
I believe you can only single out keys in indexes on embedded maps, as mentioned in the docs.

Reply all
Reply to author
Forward
0 new messages