1

I need to get all events as sub documents (array of events) which contain _playerid = somevalue, is that can be done with AQL in ArangoDB?

Sample doc:

{
    "livescore": {
        "league": [
            {
                "match": {
                    "home": {
                        "_goals": "2",
                        "_id": "2337787",
                        "_name": "Defensa y Justicia"
                    },
                    "away": {
                        "_goals": "3",
                        "_id": "2337780",
                        "_name": "Colon Santa FE"
                    },
                    "events": {
                        "event": [
                            {
                                "_assist": "",
                                "_assistid": "",
                                "_extra_min": "",
                                "_id": "22295244",
                                "_minute": "22",
                                "_player": "J. Tejera",
                                "_playerid": "2405930",
                                "_result": "",
                                "_team": "home",
                                "_type": "yellowcard"
                            }
                        ]
                    },
                    "ht": {
                        "_score": "[1-1]"
                    },
                    "ft": {
                        "_score": "[2-3]"
                    },
                    "_alternate_id": "4100536",
                    "_alternate_id_2": "4328174",
                    "_commentary": "True",
                    "_date": "12.05.2015",
                    "_id": "4218094",
                    "_static_id": "12051523377872337780",
                    "_status": "FT",
                    "_time": "00:10"
                },
                "_country": "argentina",
                "_name": "Argentina: Primera Division",
                "_cup": "False",
                "_id": "2914",
                "_sub_id": "29144"
            },
            {
                "match": [
                    {
                        "home": {
                            "_goals": "?",
                            "_id": "2337758",
                            "_name": "Berazategui"
                        },
                        "away": {
                            "_goals": "?",
                            "_id": "2337826",
                            "_name": "General Lamadrid"
                        },
                        "events": "",
                        "ht": {
                            "_score": ""
                        },
                        "_alternate_id": "4106986",
                        "_alternate_id_2": "4328905",
                        "_commentary": "False",
                        "_date": "12.05.2015",
                        "_id": "4224541",
                        "_static_id": "12051523377582337826",
                        "_status": "18:00",
                        "_time": "18:00"
                    },
                    {
                        "home": {
                            "_goals": "?",
                            "_id": "2337842",
                            "_name": "Justo José de Urquiza"
                        },
                        "away": {
                            "_goals": "?",
                            "_id": "2337850",
                            "_name": "Laferrere"
                        },
                        "events": "",
                        "ht": {
                            "_score": ""
                        },
                        "_alternate_id": "4106988",
                        "_alternate_id_2": "4329005",
                        "_commentary": "False",
                        "_date": "12.05.2015",
                        "_id": "4224543",
                        "_static_id": "12051523378422337850",
                        "_status": "18:00",
                        "_time": "18:00"
                    }
                ],
                "_country": "argentina",
                "_name": "Argentina: Primera C Metropolitana",
                "_cup": "False",
                "_id": "2912",
                "_sub_id": "29120"
            }
        ],
        "_updated": "12.05.2015 06:41:07",
        "_sport": "soccer"
    }
}

1 Answer 1

4

I think yes. I tried this with your test data:

FOR d in YourData
    LET leagueList = d.livescore.league
    FOR league IN leagueList
        LET eventList = league.match.events
        FILTER !IS_NULL(eventList) 
        LET eventList2 = eventList.event
        FOR event IN eventList2
            FILTER event._playerid == "2405930"
            RETURN event

Of course I am not sure if I understand your data modell / problem correctly, but maybe already this example helps you.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.