Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8854257
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:50:30+00:00 2026-06-14T13:50:30+00:00

I know this question was asked several times, but as far as my search

  • 0

I know this question was asked several times, but as far as my search skills go, every post is how to implement this in a SQL database, and no mention of NoSQL databases.

I have documents for which I want to implement a tagging feature.
Users will be able to tag them with whatever string they want, and then I need to be able to query the documents as fast as possible (by these generic tags)

Should I have a String array for my tags (which would allow me to support any number of tags), like this

{"_id":"aaa", "prop":"value", "tags":["tag1","tag2","tagN"]}

or limit the amount of tags to, say, 5, and have them as different properties, like this

{"_id":"aaa", "prop":"value", "tag1":"value", "tag2":"value", "tag3":"value" }

Which structure would be better for fast querying, specifically in mongodb?

Using the second structure would allow me to index the collection by this fields, but are 5 indexes recommended? Should I have less tags?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T13:50:31+00:00Added an answer on June 14, 2026 at 1:50 pm

    You simply want to use an array, the first example you have. That will allow you to have a consistent model and indexes.

    {"_id":"aaa", "prop":"value", "tags":["tag1","tag2","tagN"]}
    

    If you index a field that contains an array, MongoDB indexes each value in the array separately, in a “multikey index.”[1]

    [1] http://docs.mongodb.org/manual/core/indexes/#multikey-indexes

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this question was asked several times, but I found no working answer.
I know this question has been asked several times on SO, but none of
I know this question has been asked several times but the answers given don't
I know this question has been asked several times for sure, but I have
I know this question has been asked for several times, but I am helpless
I know this question has been asked several times, but I would like to
Well, first I know that this question was already asked several times. But I
I know this question has been asked several times, but I can't quite seem
I know that this question have been asked several times. But I can't get
I know that this question has been asked several times and I've read all

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.