Skip to content
Studio 3T - The professional GUI, IDE and client for MongoDB
  • Tools
    • Aggregation Editor
    • IntelliShell
    • Visual Query Builder
    • Export Wizard
    • Import Wizard
    • Query Code
    • SQL Query
    • Connect
    • Schema Explorer
    • Compare
    • SQL ⇔ MongoDB Migration
    • Data Masking
    • Task Scheduler
    • Reschema
    • More Tools and Features
  • Solutions
  • Resources
    • Knowledge Base
    • MongoDB Tutorials & Courses
    • Tool/Feature Documentation
    • Reports
    • Case Studies
    • Whitepapers
    • Blog
    • Testimonials
    • Community
  • Contact us
    • Contact
    • Sales Support
    • Feedback and Support
    • Career
    • About Us
  • Store
    • Buy Now
    • Preferred Resellers
    • Team Pricing
  • My License
  • Download
search

Studio 3T Knowledge Base

  • Documentation
  • Tutorials
  • Workshops
Take the fastest route to learning MongoDB. Cover the basics in two hours with MongoDB 101, no registration required.
Start the free course

Value Search

Posted on: 23/06/2022 by DJ Walker-Morgan

About Value Search

Value Search is a new feature in Studio 3T. It allows users to perform wide-ranging searches on the values stored in a collection, database, or server. By default, for any value search, Studio 3T will scan every document. It will search for a text (or regular expression) match in every field value that exists in the document. 

This includes all embedded documents and arrays. Value Search will then report back on what matched. This will include the path to the matched field.

Starting Value Search

To open a Value Search view, select a collection, database, or server in the Connection Tree in the Studio 3T window. Then either select File > Open Value Search or right-click on the selected item and choose Open Value Search.

The Value Search view will open. The tab title reflects where any future search take place.

Below that are three indicators. The first shows the server in use. The second is a selector for the which database to search. The third is a selector for which collection, within that database, to search. If you select a server for your Value Search, the second selector will default to <all databases> and the collection selector will be set to <all collections>.

Selecting a database when opening Value Search, or adjusting the database selector to a particular database will enable the collections selector.

This restricts the search to the selected database, but can still search <all collections> within that database. 

Selecting a collection when opening Value Search, or adjusting the Collection selector to a particular collection will further restrict the search to that particular collection.

Performing a Value Search

Once you have selected the scope of your Value Search, you can enter a search term in the search field. The search term can be plain text or a regular expression. 

The components of the Value Search bar
The components of the Value Search bar

If you wish the search to be case-sensitive, check the Match Case field to toggle case-sensitive searches on.

Check the RegEx field to toggle the use of Regular Expressions if you want to use a regular expression as a search term. Value Search’s regular expressions use the Java regular expression engine. Refer to Regular Expressions In Studio 3T for a reference to the formats of regular expression accepted.

We will examine the Advanced Options toggle later in this article.

The search term is, by default, a match with plain text. The text will match anywhere in a value. For many use cases, this is sufficient to home in on relevant fields. Use regular expressions where you want more defined precision in your matches.

Value Conversion

Note that when searching, values in the database documents which are not string types are converted to strings.

For example, numbers present as strings so a value search for 10 as plain text would match with 10, 100, 90.10 stored as numbers. It would also match with 10/6/22, a stored date converted to a string, as well as K100 (a string which contains a number).

Plain Text searches will always simply match the sequence of characters.

Viewing Value Search Results

Pressing the Return key in the search field or clicking on the Search button begins the search. You can follow how the search is doing in the lowe left of the view, where a progress meter and count of matches is shown. Also in the lower left is a “cancel” button (red circle with cross) which can terminate the search early.

Results showing for a simple value search
Results showing for a simple value search

Each match is displayed in the five-column table. Whilst you can interact with the table as the search runs, the search term controls are only enabled when the search is complete. You will have to stop the search, or wait for it to finish, before you can adjust those settings.

Each row is made up of five elements, each one related to a match found by Value Search:

Database: The name of the database where this match is.

Collection: The name of the collection where this match is.

_id: The _id field of the document where the match is.

Path: The path, from the document’s root, to the field where the match is. Paths display in Studio 3T format. This is a field name that is optionally followed by a > and either a number or another field name. A number usually represents the index value of an array. This repeats as needed.

Value: The value of the field in which a match is found.

The Database, Collection, _id, and Path allow you to locate precisely where the value match is. 

The particular parts of Value that match are shown with a yellow background.

Viewing Matched Documents

For any match displayed in Value Search, you have two options.

  • Double-Clicking the row will open the document containing the match in the Document JSON Viewer. You can only view the document here.
  • Right-Clicking on the row will display the context menu for the row.

    View Document, like double-clicking, opens the document in the collection using the Document JSON Viewer.
    Open in Collection Tab will open a new Collection Tab with a query that selects only the matched document. From the Collection Tab, you can edit fields inline or view and edit the matched Document.
Options for Value Search matched documents
Options for Value Search matched documents

Advanced Options

Advanced options enable an extra level of control over how Value Search examines collections. 

Before scanning any collection’s documents, Value Search runs a query which will select the documents it searches. By default, this is an empty query which returns all documents in the collection. The Advanced options let you control what that query is. This allows you to focus search on specific fields, reduce the number of documents examined, or pre-sort the results.

You can create queries using the Collections Tab and Visual Query Builder. They can then be copy and pasted, or saved and loaded, into the Advanced options.

Query

The Query field takes a MongoDB query document specification. It is a pre-filtering stage for the documents in the value search. For example, if you only want to search documents where the country field is not “United States”, then you can set the query to:

{ “country”: { $ne: “United States” } }

Any document where the country field is not “United States” will move on to the Value Search. Note that in this example, the result of the query would also return documents that did not have a country field at all (because null is not equal to United States). When doing a Value Search with a query on multiple collections, remember that the same query will run on all the collections. If the query fails to match any documents – for example, because a field is being present in a collection – no fields in that collection will go on to be in the value search.

Projection

The Projection field is useful in reducing the number of fields that pass into the Value Search. By selecting fields for inclusion or exclusion, you can make sure that Value Search is retrieving less of the documents, but still thoroughly searching the rest of the fields. For example, if your collections have a large text record attached called notes which you don’t want searched, setting the Projection to { notes: 0 } will exclude that one field from the Value Search. Again, this will be apply to all collections in scope.

Skip and Limit

Skip and Limit will, as they do in the Collections Tab and other queries, skip over a number of documents and then limit the number of documents returned by the query. If you want to only search 1000 documents in a collection, starting after the first 2000 documents, then setting Skip to 2000 would skip the first 2000 documents and setting Limit to 1000 would restrict the number of returned documents to a maximum of 1000.

Sort

Use the Sort field in Advanced options if you have want the results to appear in a particular order. This will pre-sort the documents before they are passed on to the Value Search. Again, it takes the same Sort specification as used in the Collections tab query bar and Visual Query Builder. 

That is a JSON list of field names with the values -1 or 1 to determine ascending or descending sorting for that field. Setting the Sort field to { birthdate: 1, username: 1} will sort the documents by ascending birthdate field value and ascending username text field value.

Here, we are doing a value search that focusses on just the name and username fields, with a window that scans 50 documents (after skipping ten) from a collection sorted by birthdate and username. As you can see, this limits the results.


How helpful was this article?
This article was hideous
This article was bad
This article was ok
This article was good
This article was great
Thank you for your feedback!

About The Author

DJ Walker-Morgan

Dj has been around since Commodore had Pets and Apples grew everywhere. With a background in Unix and development, he's been around the technology business writing code or writing content ever since.

Article navigation

Related articles

  • The Value of Value Search – A Christmas Tale
  • What’s New in Studio 3T 2021.10 | Value Search, Better Task Scheduling and Import Data Masking
  • What’s New in Studio 3T 2019.7 | Session Restore, Improved Search & More
  • Lesson 4, Exercise 2: Using Visual Query Builder to query a single array value
  • The Value of a Regular Expression: #Studio3T_AMA

Studio 3T

MongoDB Enterprise Certified Technology PartnerSince 2014, 3T has been helping thousands of MongoDB developers and administrators with their everyday jobs by providing the finest MongoDB tools on the market. We guarantee the best compatibility with current and legacy releases of MongoDB, continue to deliver new features with every new software release, and provide high quality support.

Find us on FacebookFind us on TwitterFind us on YouTubeFind us on LinkedIn

Education

  • Free MongoDB Tutorials
  • Connect to MongoDB
  • Connect to MongoDB Atlas
  • Import Data to MongoDB
  • Export MongoDB Data
  • Build Aggregation Queries
  • Query MongoDB with SQL
  • Migrate from SQL to MongoDB

Resources

  • Feedback and Support
  • Sales Support
  • Knowledge Base
  • FAQ
  • Reports
  • Case Studies
  • White Papers
  • Testimonials
  • Discounts

Company

  • About Us
  • Blog
  • Careers
  • Legal
  • Press
  • Privacy Policy
  • EULA

© 2022 3T Software Labs GmbH. All rights reserved.

  • Privacy Policy
  • Cookie settings
  • Impressum
When you click "Accept", you are agreeing to cookies being on your device. They may improve site navigation, site usage analysis, or the relevance of messages. It is up to you which cookies are enabled. Read our Privacy Policy.
Manage cookies
Accept
✕

Privacy Preference Center

A cookie is a small file of letters and numbers that is downloaded on to your computer when you visit a website. Cookies are used by many websites and can do a number of things, eg remembering your preferences, recording what you have put in your shopping basket, and counting the number of people looking at a website. In the form below you can choose which cookies, except for essential cookies, to allow or disable.

Accept all cookies

Manage consent preferences

Essential cookies are strictly necessary to provide an online service such as our website or a service on our website which you have requested. The website or service will not work without them.

Performance cookies allow us to collect information such as number of visits and sources of traffic. This information is used in aggregate form to help us understand how our websites are being used, allowing us to improve both our website’s performance and your experience.

Functional cookies collect information about your preferences and choices and make using the website a lot easier and more relevant. Without these cookies, some of the site functionality may not work as intended.

Social media cookies are cookies used to share user behaviour information with a third-party social media platform. They may consequently effect how social media sites present you with information in the future.

Accept selected