Skip to main content
Version: V1.3.0

Operators

Operators are generally used to connect operands or parameters and return results. In terms of syntax, operators can appear before, after, or between operands.

Operator examples​

Data filtering (where)​

Equal to​

Use $eq to indicate equal to, as follows:

where: { category: { $eq: "AI" } }

You can also use the shorthand form, as follows:

where: { category: "AI" }

Not equal to​

Use $ne to indicate not equal to, as follows:

where: { category: { $ne: "ML" } }

Greater than​

Use $gt to indicate greater than, as follows:

where: { score: { $gt: 80 } }

Greater than or equal to​

Use $gte to indicate greater than or equal to, as follows:

where: { score: { $gte: 90 } }

Less than​

Use $lt to indicate less than, as follows:

where: { score: { $lt: 60 } }

Less than or equal to​

Use $lte to indicate less than or equal to, as follows:

where: { score: { $lte: 50 } }

Contains​

Use $in to indicate contains, as follows:

where: { tag: { $in: ["ml", "python", "ai"] } }

Does not contain​

Use $nin to indicate does not contain, as follows:

where: { tag: { $nin: ["deprecated", "obsolete"] } }

Logical OR​

Use $or to indicate logical OR, as follows:

where: {
$or: [
{ category: "AI" },
{ category: "ML" }
]
}

Logical AND​

Use $and to indicate logical AND, as follows:

where: {
$and: [
{ category: { $eq: "AI" } },
{ score: { $gte: 90 } }
]
}

Text filtering (where_document)​

Full-text search (contains substring)​

Use $contains to indicate full-text search, as follows:

whereDocument: { $contains: "machine learning" }

Regular expression​

Use $regex to indicate regular expression, as follows:

whereDocument: { $regex: "AI|ML|DL" }

Logical OR​

Use $or to indicate logical OR, as follows:

whereDocument: {
$or: [
{ $contains: "AI" },
{ $contains: "artificial intelligence" }
]
}

Logical AND​

Use $and to indicate logical AND, as follows:

whereDocument: {
$and: [
{ $contains: "machine learning" },
{ $contains: "deep learning" }
]
}