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

  • Home
  • SEARCH
  • 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 6835689
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:15:44+00:00 2026-05-26T23:15:44+00:00

I spent several hours reading through docs and forums, trying to find a solution

  • 0

I spent several hours reading through docs and forums, trying to find a solution for the following problem:

In A Mongo database, I have a collection with some unstructured data:

{"data" : "some data" , "_id" : "497ce96f395f2f052a494fd4"}

{"more_data" : "more data here" ,"recursive_data": {"some_data": "even more data here", "_id" : "497ce96f395f2f052a4323"}

{"more_unknown_data" : "string or even dictionaries" , "_id" : "497ce96f395f2f052a494fsd2"}

…

The catch is that the elements in this collections don’t have a predefined structure and they can be unlimited levels.

My goal is to create a query, that searches through the collection and finds all the elements that match a regular expression( in both the keys and the values ).

For example, if I have a regex: ‘^even more’ – It should return all the elements that have the string "even more" somewhere in the structure. In this case – that will be the second one.

  • 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-05-26T23:15:45+00:00Added an answer on May 26, 2026 at 11:15 pm

    Simply add an array to each object and populate it with the strings you want to be able to search on. Typically I’d lowercase those values to make case-insensitive search easy.

    e.g. Tags : [“copy of string 1”, “copy of string 2”, …]

    You can extend this technique to index every word of every element. Sometimes I also add the field with an identifier in front of it, e.g. “genre:rock” which allows searches for values in specific fields (choose the ‘:’ character carefully).

    Add an index on this array and now you have the ability to search for any word or phrase in any document in the collection and you can search for “genre:rock” to search for that value in a specific field.

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

Sidebar

Related Questions

I have spent several hours trying to find a means of writing a cross
I have spent several hours today reading up on doing Custom Routing in ASP.NET
I have now spent several hours trying to figure this out. I have this
I have spent the last several hours trying to get this to work and
This afternoon I spent several hours trying to find a bug in my custom
I have spent several hours with this SQL problem, which I thought would be
I'm kind of new to JAXB and validation, and have spent several hours trying
I spent hours researching the problem, and just want to share a solution in
I hope someone can help me as I've already spent several hours trying to
I just spent several hours of my life debugging this problem. I'm documenting it

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.