Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-53574

Support for index on multiple array field

    XMLWordPrintableJSON

Details

    • Icon: New Feature New Feature
    • Resolution: Duplicate
    • Icon: Major - P3 Major - P3
    • None
    • None
    • Querying
    • None
    • Server Triage

    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,

       

       

      Attachments

        Activity

          People

            backlog-server-triage Backlog - Triage Team
            hitesh.baldaniya@contentstack.com Hitesh Baldaniya
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: