[SERVER-53574] Support for index on multiple array field Created: 05/Jan/21  Updated: 06/Dec/22  Resolved: 05/Jan/21

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: None
Fix Version/s: None

Type: New Feature Priority: Major - P3
Reporter: Hitesh Baldaniya Assignee: Backlog - Triage Team
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-826 Allow indexing of several arrays Backlog
Assigned Teams:
Server Triage
Participants:

 Description   

Hi Team,

I know currently MongoDB does not support having an index on the multiple array fields which is causing the implementation issue.

 

Consider the following example where we have 2 fields which are array and on both of them, we need the indexes.

 

Consider the following example where we have tags in the document and also that same document is shared among the other branches, now I want to filter the data based on branch and tag something like as follows.

 

{
  tags: ["tech", "blog", "discussion"],
  branches: ["dev", "staging"]
}

 

Fetch the document where the tag is tech, blog and belongs to dev branch

db.collection.find({tags: {$in: ["tech", "blog"]}, branches: "dev"}) in order to improve the performance I need the index on both the fields but which is not possible for now.

 

The only workaround which I see is to create multiple copies for each branch which will avoid https://docs.mongodb.com/manual/core/index-multikey/#compound-multikey-indexes index limitations and it will increase the data size and documents count in the collection.

 

Thanks,

 

 



 Comments   
Comment by Hitesh Baldaniya [ 06/Jan/21 ]

Thanks Eric, I will check the blog post and if facet search or reorganizing data makes sense.

Comment by Eric Sedor [ 05/Jan/21 ]

Hi hitesh.baldaniya@contentstack.com,

We are tracking this request in SERVER-826, so I'm going to close this ticket as a duplicate. Can you watch that ticket for updates, and comment there with the value the feature would bring for you?

For what it's worth, you may find that a faceted search-focused data model can help with these sorts of queries, depending on your use-case.

Sincerely,
Eric

Generated at Thu Feb 08 05:31:18 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.