Can't figure out this error for INDEX_OF method

data.frequent_words1 is a list of objects. I Want to get the index of object in which the key stringValue for wordID holds the value "w2".

Example:

[
    {
        "name": "projects/XXXXXXXXXXXXX/databases/(default)/documents/frequent_words/FGuVN0cUa9L4I5D7ROJv",
        "fields": {
            "rank": {
                "integerValue": "1"
            },
            "word": {
                "stringValue": "The"
            },
            "translation": {
                "stringValue": "a, o, as, os"
            },
            "wordID": {
                "stringValue": "w1"
            }
        },
        "createTime": "2021-07-28T21:18:20.384182Z",
        "updateTime": "2021-07-31T17:38:05.898951Z"
    },
    {
        "name": "projects/XXXXXXXXXXXXX/databases/(default)/documents/frequent_words/qrlRe6pS2mMJnmB9FX96",
        "fields": {
            "rank": {
                "integerValue": "2"
            },
            "word": {
                "stringValue": "To be"
            },
            "translation": {
                "stringValue": "ser, estar"
            },
            "wordID": {
                "stringValue": "w2"
            }
        },
        "createTime": "2021-07-28T21:24:34.242452Z",
        "updateTime": "2021-07-31T17:38:16.807765Z"
    }
]

You need to do it more like this:

INDEX_OF(data.frequent_words1, FIND(data.frequent_words1, item.fields.stringValue == “w2”))

1 Like