Skip to main content
All CollectionsCommon Errors
Cannot index parallel arrays
Cannot index parallel arrays

Parallel arrays error explained.

Praise Magidi avatar
Written by Praise Magidi
Updated over 3 weeks ago

Message

Cannot index parallel arrays.

Cause

The error "Cannot index parallel arrays" happens because Buffers do not support indexing multiple fields on arrays with more than one element (parallel arrays).

Parallel arrays are multiple arrays where each array has more than one value, and these arrays are related by position or are supposed to be indexed together. For instance:

json

{

"field1": [1, 2, 3],

"field2": ["a", "b", "c"]

}

Here, `field1` and `field2` are parallel arrays. For example:

`field1[0]` corresponds to `field2[0]`

`field1[1]` corresponds to `field2[1]`

Resolution

  • Restructure your data to avoid parallel arrays (e.g., use arrays of subdocuments).

  • Index a single array field when possible.

  • Flatten or transform the data to maintain relationships without storing parallel arrays.

Error Detail

{
"error": {
"errorResponse": {
"message": "cannot index parallel arrays [Referrals] [Accounts]",
"code": 171,
"writeErrors": [
{
"err": {
"index": 504,
"code": 171,
"errmsg": "cannot index parallel arrays [Referrals] [Accounts]",
"errInfo": null,
"op": {
"q": {
"$and": [
{
},
"message": "cannot index parallel arrays [Referrals] [Accounts]",
"errorMessage": "cannot index parallel arrays [Referrals] [Accounts]",
"commandProcessingError": null
}

Did this answer your question?