G
G
gerrrper2014-10-08 11:45:10
NoSQL
gerrrper, 2014-10-08 11:45:10

Fetching data from Arango, how to find matches in an array?

I have a collection with the following structure:

{
  "user": 1,
  "timestamp": 216354113151,
  "message": "asddsaasddsaa",
  "data": [
    "name=Jack&hash=s5w464t35w145df13s5df4sdg&id=2",    
    "name=Mansonack&hash=xga5fd7h68745v46ed2&id=18",
  ]
}

I need to find an element of a collection that has a value in the data key that contains a string with the xga5fd7h68745v46ed2
substring. Is it possible to write such a query? What will it look like?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya Rumyantsev, 2017-08-16
@explosivebit

It is better to store all this in a separate field and hang a full-text index on it
. But there is a solution, below

LET rs = (FOR item IN rcity
RETURN {
    result: item.data[* FILTER CONTAINS(CURRENT, "hash=s5w464t35w145df13s5df4sdg")  RETURN r ]
})
RETURN rs[0].result[0]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question