简体   繁体   中英

how to use indexes in arangodb graph search?

i'm evaluating ArangoDb for my application. I have a data model like a file system, with a Items document collection and a ItemsParents edge collection with parent-child relations about Items.

Now i would like to find all childs of a specific item, with a specific attribute

Ex: All childs of A with property Properties.Age.Value = 20

so i created an hash index over Items.Properties.Age.Value, and design this AQL query:

FOR item 
    IN GRAPH_NEIGHBORS('ItemsGraph', 'Items/A', 
       { direction : 'outbound', 
         includeData: true,
         neighborExamples : { 'Properties.Age.Value': 20 }
       })
RETURN { Id: item._key, Name: item.Name } 

the above query work well, but no index are used, so it perform a full scan of Items collection for test Properties.Age.Value filter.

How to design the query so that it performance efficiently using index and avoid a collection scan?

Thanks

Currently ArangoDB can only utilize edge indices in graph operations;

Not using GRAPH_NEIGHBOURS may offer using the index, but then you would have to filter for neighbours yourself.

Vertex centric indices, which would offer that kind of index-support may arive in one of the next two ArangoDB Releases.

[edit] Meanwhile this is possible with newer ArangoDB releases.

GRAPH_NEIGHBOURS was integrated into the traversal engine . You would now create a combined index on Age and _from . You should use db._explain() to inspect the usage of indices.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM