Back to blog
|Radoslav Toth

Smart search

The majority of queries we execute on MongoDB collections are very simple. We usually search for an _id, an email or username and we do this many times over...

Smart search

The majority of queries we execute on MongoDB collections are very simple. We usually search for an _id, an email or username and we do this many times over every day. To make such searches simple and fast, Mingo provides a few great hacks for you.

Value as query

First of all, indexed fields can be searched swiftly by using the value as query. For example: let's say you have a collection where the fields "slug" and "city" are indexed. If you enter a string expensive in the query, Mingo will search for the value in all indexed fields and show you the resulting query that found results. In this case it would be {slug: "expensive"}.

Since most of the often queried fields are indexed (or at least, should be...), such searches will be fast and efficient.

The above will automatically turn into this:

You may go even further, and instead of specific value, you may enter a regular expression to search for.

For example: /sales/i will search for documents where the indexed fields match "sales" in case in-sensitive mode.

Paste & Go

Paste & Go is a great feature, especially combined with the Smart search mentioned above. Pressing CMD+G / CTRL+G will paste the current clipboard contents into the query field and submit it. The pasted value could be a regular query or just a phrase or _id copied from your admin or other app.

If the value is not an object (real query), Mingo will treat it as a value, execute the Smart search and show the resulting documents.

Dates by tags

Imagine being able to do this: { "createdAt": #lastWeek }. Before Mingo, this was not possible! Check out this article on all the options and how to use it. It is really handy.