Many thanks, that does look a lot easier to write queries for too.
On Thursday, 1 August 2019 00:47:13 UTC+1, Kerry Hormann wrote:
>
> I would think the most efficient way to do this is by using an array to
> define the list of keys. The array could be another collection, a static
> array, or even a bindVariable.
>
> Here's an example, retrieving a few documents from the list of collections:
>
> LET keys = [ '_apps', '_fishbowl', '_jobs', '_routing' ]
> FOR c IN COLLECTIONS()
> FILTER c.name in keys
> RETURN c
>
> The biggest caveat here is to make sure the filter clause is covered by an
> index. I'm using "c.name" here, which is NOT indexed (this list is
> pretty small), but "_key" is always indexed, so you should be OK.
>
> Using this pattern, you could also write your query like this:
>
> FOR doc IN myCollection
> FILTER doc._key in [ '1', '2, '3' /* etc. for 997 more keys */ ]
> RETURN doc
>
> Or this:
>
> FOR doc IN myCollection
> FILTER doc._key in @keys /* @keys is bound at runtime to your array */
> RETURN doc
>
>
>
>
> On Wednesday, July 31, 2019 at 1:57:28 AM UTC-7, Dave Challis wrote:
>>
>> Is there a preferred or most performant way of querying for a subset of
>> documents in AQL? I know there's a separate API for fetching bulk
>> documents, but this is something I need to do in the middle of a more
>> complex AQL query. I know I can use either:
>>
>> FOR doc IN myCollection
>> FILTER doc._key == "1" || doc._key == "2" || doc._key == "3" // etc.
>> for 997 more keys
>> RETURN doc
>>
>> Or I could fetch documents directly:
>>
>> RETURN [ DOCUMENT("myCollection/1"), DOCUMENT("myCollection/2"), DOCUMENT
>> ("myCollection/3"), ... ]
>>
>> Is either of these preferred? Or is there another method I might be
>> missing for doing this in AQL?
>>
>
--
You received this message because you are subscribed to the Google Groups
"ArangoDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/arangodb/45c9abf6-6b33-472d-a154-9f7f9b3dede4%40googlegroups.com.