- Describe the bug When I use Field filters variable, and Field to map to of the variable is a nested field. Logs 12-27 11:38:32 WARN middleware.process-userland-query:: Query failure :status:fail.
- PostgreSQL JSON query operators. There are two types of operators that can be used to query JSON data: (-) and (-) operators: We can pass a string or integer to these operators to identify a specific element in a JSON array that matches either the numeric position or the string match for the key.
- Analyze your MongoDB data in Metabase Getting your data from MongoDB to Metabase can be a pain. Managing pipelines for all your data sources just isn’t sustainable, but your reporting can’t be put on hold while you wait for IT or Engineering to get to your ticket.
- Hi @esaiekuitche, the Metabase repo isn't really a good place to ask questions about how to write MongoDB Aggregation Pipeline queries because they're part of the MongoDB project, not Metabase. Take a look at their documentation.
$in
¶If you are using a Metabase version earlier than 0.33, you will need to either write a SQL query that contains joins, or have your Metabase administrator set up foreign keys (they can read more about that here). If you are using Metabase 0.33 or above, you can perform joins using the Notebook editor. See something that needs fixing?
The $in
operator selects the documents where the valueof a field equals any value in the specified array. To specify an$in
expression, use the following prototype:
For comparison of different BSON type values, see the specifiedBSON comparison order.
If the field
holds an array, then the $in
operatorselects the documents whose field
holds an array that containsat least one element that matches a value in the specified array(for example, <value1>
, <value2>
, and so on).
This document describes the $in
query operator.For the $in
aggregation operator, see$in (aggregation).
Examples¶
Use the $in
Operator to Match Values¶
Consider the following example:
This query selects all documents in the inventory
collection where the qty
field value is either 5
or15
. Although you can express this query using the$or
operator, choose the $in
operator ratherthan the $or
operator when performing equality checks onthe same field.
Use the $in
Operator to Match Values in an Array¶
Metabase Mongodb Query Tutorial
The collection inventory
contains documents that include the fieldtags
, as in the following:
Then, the following update()
operation willset the sale
field value to true
where the tags
field holdsan array with at least one element matching either 'appliances'
or'school'
.
Metabase Sql
For additional examples in querying arrays, see:
For additional examples in querying, see:
Use the $in
Operator with a Regular Expression¶
The $in
operator can specify matching values using regularexpressions of the form /pattern/
. You cannot use $regex
operator expressions inside an $in
.
Consider the following example:
This query selects all documents in the inventory
collection wherethe tags
field holds either a string that starts with be
orst
or an array with at least one element that starts with be
orst
.
© MongoDB, Inc 2008-present. MongoDB, Mongo, and the leaf logo are registered trademarks of MongoDB, Inc.