You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@nifi.apache.org by BeNJ <in...@gmail.com> on 2021/09/13 07:04:12 UTC

PutMongo error when trying to use arrayFilters.

Hi,
I have a mongo document that has a multi level nested array.
I'm trying to perform a PutMongo Update with the following Update Query:
{
"customer_id": "${customer_id}"
}

And the following flowfile:
{
    "$inc": {
        "hosts.$[hostip].ports.$[portnum].port_test" : 1
    },
    "$max": {
        "hosts.$[hostip].ports.$[portnum].port_index" : "2"
    }
},
{
    "arrayFilters": [
    {
        "hostip.host": "1.1.1.1"
        },
        {
            "portnum.port": "80",
            "portnum.proto": "tcp"
        } ]
}

But I'm getting the following error:
*Failed to insert StandardFlowFileRecord[...], ...], ...] into MongoDB due
to com.mongodb.MongoWriteException: No array filter found for identifier
'hostip' in path 'hosts.$[hostip].host_ports': *
*com.mongodb.MongoWriteException: No array filter found for identifier
'hostip' in path 'hosts.$[hostip].host_ports'*

This works though a mongo client, but from what I can tell, PutMongo
ignores the arrayFilters section.
Other updates I perform with putMongo using normal $push or $set to a flat
or nested document with $elemMatch in the query, work great (I'm using
Update mode "With operators enabled")

Am I missing anything that I should try, or is this a known limitation and
I should use some external way (script maybe?) to make the update?

I appreciate any info you can share,
Thanks.
Benji