|
| 1 | +SearchOperator Helper Methods |
| 2 | +----------------------------- |
| 3 | + |
| 4 | +The {+driver-short+} provides helper methods for the following operations: |
| 5 | + |
| 6 | +.. list-table:: |
| 7 | + :widths: 40 60 |
| 8 | + :header-rows: 1 |
| 9 | + |
| 10 | + * - Operation |
| 11 | + - Description |
| 12 | + |
| 13 | + * - :atlas:`autocomplete </atlas-search/autocomplete/>` |
| 14 | + - Performs a search for a word or phrase that contains a sequence of |
| 15 | + characters from an incomplete input string. |
| 16 | + |
| 17 | + * - :atlas:`compound </atlas-search/compound/>` |
| 18 | + - Combines two or more operators into a single query. |
| 19 | + |
| 20 | + * - :atlas:`equals </atlas-search/equals/>` |
| 21 | + - Checks whether a field matches a value you specify. |
| 22 | + Maps to the ``equals()`` and ``equalsNull()`` methods |
| 23 | + |
| 24 | + * - :atlas:`exists </atlas-search/exists/>` |
| 25 | + - Tests if a path to a specified indexed field name exists in a document. |
| 26 | + |
| 27 | + * - :atlas:`in </atlas-search/in/>` |
| 28 | + - Performs a search for an array of BSON number, date, boolean, objectId, |
| 29 | + uuid, or string values at the given path and returns documents where the |
| 30 | + value of the field equals any value in the specified array. |
| 31 | + |
| 32 | + * - :atlas:`moreLikeThis </atlas-search/moreLikeThis/>` |
| 33 | + - Returns documents similar to input documents. |
| 34 | + |
| 35 | + * - :atlas:`near </atlas-search/near/>` |
| 36 | + - Supports querying and scoring numeric, date, and GeoJSON point values. |
| 37 | + |
| 38 | + * - :atlas:`phrase </atlas-search/phrase/>` |
| 39 | + - Performs a search for documents containing an ordered sequence of terms |
| 40 | + using the analyzer specified in the index configuration. |
| 41 | + |
| 42 | + * - :atlas:`queryString </atlas-search/queryString/>` |
| 43 | + - Supports querying a combination of indexed fields and values. |
| 44 | + |
| 45 | + * - :atlas:`range </atlas-search/range/>` |
| 46 | + - Supports querying and scoring numeric, date, and string values. |
| 47 | + Maps to the ``numberRange()`` and ``dateRange()`` methods |
| 48 | + |
| 49 | + * - :atlas:`regex </atlas-search/regex/>` |
| 50 | + - Interprets the query field as a regular expression. |
| 51 | + |
| 52 | + * - :atlas:`text </atlas-search/text/>` |
| 53 | + - Performs a full-text search using the analyzer that you specify in the |
| 54 | + index configuration. |
| 55 | + |
| 56 | + * - :atlas:`wildcard </atlas-search/wildcard/>` |
| 57 | + - Enables queries which use special characters in the search string that |
| 58 | + can match any character. |
| 59 | + |
| 60 | +Example Pipeline Search Stage |
| 61 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 62 | + |
| 63 | +.. note:: Atlas Sample Dataset |
| 64 | + |
| 65 | + This example uses the MongoDB Atlas sample dataset. Specifically, the |
| 66 | + ``movies`` collection in the ``sample_mflix`` database. You can learn how |
| 67 | + to set up your own free-tier Atlas cluster and how to load the sample dataset |
| 68 | + in our :ref:`quick start guide <java-get-started>`. |
| 69 | + |
| 70 | +The following code creates a search stage for a pipeline with the following filters: |
| 71 | + |
| 72 | +- Movies in the drama genre |
| 73 | +- Movies that include Sylvester Stallone in the cast, accounting for possible misspellings |
| 74 | +- Movies made between 1980 and 1989, inclusive |
| 75 | +- Movies with titles that begin with the word ``"Rocky"`` |
| 76 | + |
| 77 | +|atlas-query-operators-example| |
| 78 | + |
| 79 | +To learn more about the helper methods, see the |searchoperator-interface-api-docs|. |
0 commit comments