User Search - AND Query Involving Object Elements of Array Not Working as Expected

Overview

We search with the following query:

```
app_metadata.identities.email: "test2@gmail.com" AND app_metadata.identities.connection: "facebook"
```

The user returned from the search has the following app_metadata:
```
{
"identities": [
{
"connection": "facebook",
"email": "test1@gmail.com"
},
{
"connection": "twitter",
"email": "test2@gmail.com"
}
]
}
```

We would expect that this result would not be included since the matching attribute values are each in different objects.

Applies To

  • User Search
  • Search Query

Solution

This is a known limitation of user search. When you have an AND condition for two attributes of an object belonging to an array the search will not enforce the AND condition per object but instead across all objects of that array.

You will need to use the same query and further filter the results yourself. If you are performing the queries programatically this shouldn't be too much of an issue since you can simply iterate through each object and check whether both of its attribute values match.

Recommended content

No recommended content found...