2

I have a document with an embedded array. The array is just a bunch of strings. I recently came across some performance issues, so I decided to create an index. But it won't allow me to because the "key is too large to index".

I'm using AWS DocumentDB.

A sample doc looks like this:

{
  _id: (mongoID),
  id: (uuid),
  employees: [(uuid of another user), ...]
}

I saw the question Cannot create index in mongodb, "key too large to index" but I didn't really see how the solution applies to my question.

15
  • Can you provide a sample document and index specification. Commented Feb 28, 2020 at 9:24
  • 1
    Does this answer your question? Cannot create index in mongodb, "key too large to index" Commented Feb 28, 2020 at 9:25
  • Which MongoDB version do you use? The limit should be removed in most recent version, see Index Key Limit Commented Feb 28, 2020 at 9:28
  • @WernfriedDomscheit I'm using AWS DocumentDB, as I wrote in the question. Also added a sample doc. Commented Feb 28, 2020 at 9:31
  • @Valijon I saw that answer but didn't see how it applied to my specific question. Commented Feb 28, 2020 at 9:32

2 Answers 2

1

We just updated this functionality, you can now create an index on arrays greater than 2048 bytes and create a compound multi-key index with multiple keys in the same array.

https://aws.amazon.com/about-aws/whats-new/2020/04/amazon-documentdb-adds-improved-multi-key-indexing-capabilities/

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

Comments

0

Array Indexing

Amazon DocumentDB indexes an array as a single entry. Arrays larger than 2048 bytes cannot currently be indexed.

https://docs.aws.amazon.com/documentdb/latest/developerguide/functional-differences.html#functional-differences.array-indexing

If employees has more than 56 entries, you cannot create index

1 Comment

Creating an index on an array larger than 2048 bytes has been added: aws.amazon.com/about-aws/whats-new/2020/04/…

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.