- Full Text Search >
- $searchBeta (aggregation) >
- exists (Operator)
exists (Operator)¶
On this page
Definition¶
-
exists
¶ The
exists
operator tests if a path to a specified indexed field name exists in a document. If the specified field exists but is not indexed, the document is not included with the result set.exists
is often used as part of a compound query in conjunction with other search clauses.exists
has the following syntax:
Examples¶
The following examples use a collection called fruit
that contains
the following documents:
The fruit
collection has a Full Text Search index on the description
field
that uses the standard analyzer. The
standard
analyzer lower-cases all words and disregards common stop
words ("the", "a", "and",
etc).
Basic Example¶
The following example searches for documents which include a field
called type
:
The above query returns the first three documents of the collection. The
document with _id: 4
is not included because it does not have a
type
field.
Embedded Example¶
Use dot notation to search for embedded fields. The following example
searches for documents which have a field named lemons
embedded
within a field named quantities
.
The above query returns the following result: