Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ArangoDB AQL Non Case Sensitive Comparison

Let's imagine I have a few simple docs stored in an Arango collection like so:

[
    {"type":Cat, "quality":Fuzzy}
    {"type":Dog, "quality":Barks}
    {"type":Rabbit, "quality":Hoppy}
    {"type":Pig, "quality":Chubby}
    {"type":Red Panda, "quality":Fuzzy}
    {"type":Monkey, "quality":Hairy}
]

Now let's say a user initiates a search in my application for all animals that are 'fuzzy', all lower case. Is there a way with AQL to make a comparison that is not case sensitive? So for instance:

FOR a IN animals
    FILTER a.type.toLowerCase() == fuzzy
    RETURN a

Now I know the above example doesn't work, but it would be nice if there was a way to do this. Thanks!

like image 383
skinneejoe Avatar asked Feb 19 '14 20:02

skinneejoe


People also ask

What is AQL ArangoDB?

The ArangoDB Query Language (AQL) is similar to the Structured Query Language (SQL) in its purpose. Both support reading and modifying collection data, however AQL does not support data definition operations, such as creating and dropping databases, collections and indexes.

Which AQL operation allows you to define arbitrary values?

The LET statement can be used to assign an arbitrary value to a variable.

How do you comment on ArangoDB?

Single line comments: These start with a double forward slash and end at the end of the line, or the end of the query string (whichever is first).

What types of transformations are applied when using the built in identity analyzer?

“Identity” analyzer does nothing but treats input value as an atom, so no transformation is applied.


1 Answers

There is a LOWER string function in AQL which you can try to use in your query like this:

FOR a IN animals
    FILTER LOWER(a.quality) == 'fuzzy'
    RETURN a
like image 81
yojimbo87 Avatar answered Sep 19 '22 16:09

yojimbo87