Twas the night before Christmas and all through the Data warehouse there was yelling and shouting.
“Why did you let this happen?” cried one voice.
“Head office said the AI-powered schema designer would just take all our incoming documents and structure them in a MongoDB database efficiently,” a more patient voice explained, pointing at the screen.
“I can see! We now have hundreds of databases, thousands of collections and”, clicking on a mouse which had been barely stirring, “The most bizzare higgledy piggledy mess of arrays and embedded documents you’ve ever seen”.
“But surely we can query them somehow? We have to find all the records for Project Santa so we can get them to our client by tonight.”
“It’ll take too long!”
“Ah, but I have just the thing here” a third voice said.
“Studio 3T’s new Value Search. If I just point it at the server, enter “Santa” in the search field and…” he paused “… there… every reference to Santa anywhere in any database, collection, document, array or object….”
The Search for Values
It may sound like a Christmas miracle but Value Search has arrived in Studio 3T. In the just -released version, 2021.10, this new feature changes everything about how you search for data in your MongoDB. So what is Value Search? Essentially, it’s a powerful way to search everything on your server.
Your MongoDB server contains databases and within those, collections. You’ll be used to searching in collections for data using the Collections view in Studio 3T. Or you’ll be familiar with the find() command at the MongoDB API level. Searching like that sets a scope on where to look, the collection itself, and the named fields. When you are writing code for an application, that’s logical and great.
Is that value you are looking for is buried deep inside an array or embedded document? Or is it inside an embedded document in an array in an embedded document. It could be in a rarely queried collection created and forgotten? … If it is, then your query gets more complex. As it does so it becomes harder to come up with queries that will catch everything. If you are just browsing for data, that is a lot of work.
Let’s take this further. Imagine you have a mess of unstructured data, scattered through collections and even spread across multiple databases. And then you need to find where some string is stored throughout that data, where do you even start?
Enter Value Search
With Value Search, you can now search through everything. Go to the server, database, or collection you are interested in in Studio 3T and open the Value Search tab using the right click menu. That selection sets the initial scope of your search. Open Value Search on a server and you will search all databases and collections. When you open it on a database the you’ll search all collections in that database. Opening it on just a collection will search all all documents in that collection.
You can now give the search something to search for. Use the toggle button to the right of the search field to control Search options. The regular expression option lets you be super precise about what you want to match with, while the case sensitivity option lets your search match things in upper and lower case. And if you are wondering about numeric values and other non-string types, we convert all the values to string representations and search the string. Once you’ve entered your search term, hit return or click search and the clever bit happens.
The results you get back will come from every nook and cranny of the MongoDB databases you’ve selected. It’ll dig down into any arrays or embedded documents checking every value in the documents it searches for a match and returns to you what it found. That includes what database, collection and document it was in and the path to find that data within the JSON document. No element will be left unsearched.
Beyond Value Search
Results start appearing as soon as the search locates them. You don’t need to wait for the search to complete and Value Search doesn’t block you from working with the results as soon as you have them. You can click the stop button next to the progress meter if you have found what you are looking for. Or you can inspect the results as it searches. Double clicking on any result zooms in on the enclosing document’s JSON. That means you view a result immediately and in context. And remember, if you want you can copy the JSON results into another application or another collection in Studio 3T. The latter is especially useful if you are restructuring all Project Santa’s collections.
If you want to zoom out to the enclosing collection the document is in, right click on the result and select Open in Collections Tab. A new Collections view will open with a query selecting the particular result. You can now use the Visual Query Builder and the resulting document to explore the collection.
When you are developing queries for a newly imported collection of data, Value Search can help you explore just that collection and help you map out the underlying structure in your data. That’s what helped our friends at the data warehouse work out where the misfiring AI put all the data and with the help of Studio 3T’s Reschema, they set about getting it all in the right shape for Project Santa’s gift delivery system.
So in this tale, Value Search saved Christmas, and it’s already in your latest Studio 3T 2021.10 update so it could help you everyday too. Enjoy the magic of searching everything inside a MongoDB server this Christmas.
Download and try all of Studio 3T’s features today with the 30 day free trial.
Try Studio 3T