Hi,

you are right, the ANY IN and ALL IN array operators currently do not 
provide index support.
However, some queries that use ANY IN and ALL IN can be rewritten to use 
indexes.

Let's assume there's a collection named "posts" with an array index on 
attribute "tags[*]".

The following query uses ANY IN but won't use the index: 

  FOR doc IN posts
    FILTER ["foo", "bar"] ANY IN doc.tags[*]
    RETURN doc

If that query is rewritten as follows, it will use the array index:

  FOR doc IN posts
    FILTER "foo" IN doc.tags[*] || "bar" IN doc.tags[*]
    RETURN doc


The same can be achieved for queries that use ALL IN.
The following query uses ALL IN but won't use the index: 

  FOR doc IN posts
    FILTER ["foo", "bar"] ALL IN doc.tags[*]
    RETURN doc

Rewriting it as follows will make it use the array index:

  FOR doc IN posts
    FILTER "foo" IN doc.tags[*] && "bar" IN doc.tags[*]
    RETURN doc


This workaround will work for queries in which the lookup values are known 
when the query is constructed, i.e. when the lookup values are either 
literals or bind parameters. 
The client application then could send the "||"-/"&&"-combined filter 
conditions instead of an ANY IN/ALL IN.

The workaround is inappropriate when the lookup value is only known at 
query runtime, e.g. when the lookup value comes from a join or other 
dynamic expressions.

A fix that would work in all cases requires adding support for ANY IN/ALL 
IN to indexes and the query optimizer, which is non-trivial.

Best regards
J


Am Freitag, 16. Dezember 2016 07:05:27 UTC+1 schrieb Ilkka Huotari:
>
> I noticed that I can't use a certain feature in my app if indexes are not 
> supported with ANY IN (and maybe ALL IN) filters. And currently at least 
> they don't seem to be.
>
> Do you plan to support indexes with ANY IN filters? Any idea when it might 
> come?
>
> Since arrays are already supported when searched by one item, it doesn't 
> seem too costly to support multiple items?
>
> Thanks,
> Ilkka
>
>
>

-- 
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].
For more options, visit https://groups.google.com/d/optout.

Reply via email to