1
votes

I have collection of documents. Document have a field which value is an array of maps (for example: map with one field name). Structure is like that:

{
  arrayfield: [
    {
       name: "value1",
    },
    {
       name: "value2",
    }
  ]
}

I want to fetch documents whose arrayfieds all maps contain values from specified array. Documentation says that I can use containsall operator. I use it in this way:

select from SomeCollection where arrayfiled containsall (name in ['value1','value2'])

But this construction always returns empty result. Where I do mistake? Thanks.

PS: If my question not understandable, I can post more detailed example of the collection and and a result which I want to receive.

2
What type is the property arrayfiled ? - Alessandro Rota
Can you post the result of the following query "select from SomeCollection" ? I would understand if arrayfiled is of type embedded, embeddedList, embeddedSet, emnbeddedMap, link, linkList, linkMap, linkSet - Alessandro Rota
I can do it later. May be if it will help: I work with baasbox which uses OrientDB - bartl
@AlessandroRota here is the respond with I can get from baasbox: [ {"@rid":"#26:3", "@version":17, "@class":"SomeClass", "title":"some title", "arrayfield":[ {"name":"value1"}, {"name":"value2"} ], "projectid":"e251799e-8706-4eb8-a414-ad8524b00edb", "id":"7ebe866e-53a0-472d-96a1-98982e9ab274", "_allowRead":[{"@rid":"#4:4","@version":4,"@class":"ORole","name":"anonymous","isrole":true}], "_allowUpdate":[{"@rid":"#5:5","@version":1,"@class":"OUser","name":"bartl"}], "_allowDelete":["#5:5"], "_author":"bartl"} ] - bartl
@AlessandroRota I used this request to determine the type of field: select arrayfield.type() as type from SomeClass and it returned EMBEDDEDLIST - bartl

2 Answers

1
votes

Found a solution to solve my issue without containsAll:

select from SomeCollection where not (arrayfield contains (fname not in ["value1", "value2"]))

0
votes

Try the following query

select from SomeCollection where arrayfiled.name contains "value1" and arrayfiled.name contains "value2"

enter image description here