@@ -10,104 +10,49 @@ Text Search
10
10
:depth: 1
11
11
:class: singlecol
12
12
13
- Overview
14
- --------
13
+ MongoDB offers a premium full-text search solution, MongoDB Atlas
14
+ Search, for MongoDB Atlas users and a legacy text search capability for
15
+ self-managed deployments.
15
16
16
- MongoDB supports query operations that perform a text search of string
17
- content. To perform text search, MongoDB uses a
18
- :ref:`text index <index-feature-text>` and the :query:`$text` operator.
17
+ MongoDB Atlas Search
18
+ --------------------
19
19
20
- .. note::
21
-
22
- .. include:: /includes/extracts/views-unsupported-text-search.rst
23
-
24
- Example
25
- -------
26
-
27
- This example demonstrates how to build a text index and use it to find
28
- coffee shops, given only text fields.
29
-
30
- Create a collection ``stores`` with the following documents:
31
-
32
- .. code-block:: javascript
33
-
34
- db.stores.insert(
35
- [
36
- { _id: 1, name: "Java Hut", description: "Coffee and cakes" },
37
- { _id: 2, name: "Burger Buns", description: "Gourmet hamburgers" },
38
- { _id: 3, name: "Coffee Shop", description: "Just coffee" },
39
- { _id: 4, name: "Clothes Clothes Clothes", description: "Discount clothing" },
40
- { _id: 5, name: "Java Shopping", description: "Indonesian goods" }
41
- ]
42
- )
43
-
44
- Text Index
45
- ~~~~~~~~~~
46
-
47
- .. include:: /includes/fact-text-index.rst
48
-
49
- .. include:: /includes/fact-create-text-index.rst
50
-
51
- ``$text`` Operator
52
- ~~~~~~~~~~~~~~~~~~
53
-
54
- .. include:: /includes/fact-use-text-operator.rst
55
-
56
- Exact Phrase
57
- ````````````
20
+ For MongoDB Atlas users, MongoDB's Atlas Search supports fine-grained
21
+ text indexing using several kinds of text analyzers and searching using
22
+ a rich query language. To learn more about full-text search indexes and
23
+ :pipeline:`$search` queries, see:
58
24
59
- You can also search for exact phrases by wrapping them in double-quotes.
60
- If the ``$search`` string includes a phrase and individual terms, text search
61
- will only match documents that include the phrase.
25
+ - :atlas:`Atlas Search Aggregation Pipeline Stages
26
+ </reference/atlas-search/query-syntax/>`
27
+ - :atlas:`Defining Atlas Search Indexes
28
+ </reference/atlas-search/index-definitions/>`
29
+ - :atlas:`Running Atlas Search Queries
30
+ </reference/atlas-search/searching/>`
62
31
63
- For example, the following will find all documents containing
64
- "coffee shop":
65
-
66
- .. code-block:: javascript
67
-
68
- db.stores.find( { $text: { $search: "\"coffee shop\"" } } )
69
-
70
- For more information, see :ref:`text-operator-phrases`.
71
-
72
- Term Exclusion
73
- ``````````````
74
-
75
- To exclude a word, you can prepend a "``-``" character. For example, to
76
- find all stores containing "java" or "shop" but not "coffee", use the
77
- following:
78
-
79
- .. code-block:: javascript
80
-
81
- db.stores.find( { $text: { $search: "java shop -coffee" } } )
82
-
83
- Sorting
84
- ```````
85
-
86
- MongoDB will return its results in unsorted order by default. However,
87
- text search queries will compute a relevance score for each document
88
- that specifies how well a document matches the query.
32
+ .. include:: /includes/fact-atlas-search-languages.rst
89
33
90
- To sort the results in order of relevance score, you must explicitly
91
- project the :expression:`$meta` ``textScore`` field and sort on it:
34
+ Legacy Text Search
35
+ ------------------
92
36
93
- .. code-block:: javascript
37
+ For self-managed deployments, MongoDB's legacy text search capability
38
+ supports query operations that perform a text search of string content.
39
+ To perform text search, MongoDB uses a :ref:`text index
40
+ <index-feature-text>` and the :query:`$text` operator.
94
41
95
- db.stores.find(
96
- { $text: { $search: "java coffee shop" } },
97
- { score: { $meta: "textScore" } }
98
- ).sort( { score: { $meta: "textScore" } } )
42
+ .. note::
99
43
100
- Text search is also available in the aggregation pipeline.
44
+ .. include:: /includes/extracts/views-unsupported-text-search.rst
101
45
102
- Language Support
103
- ----------------
46
+ Users running MongoDB software locally can find information on the
47
+ legacy text search here:
48
+
49
+ - :doc:`Text Indexes </core/link-text-indexes/>`
50
+ - :doc:`Text Search Operators </core-text-search-operators/>`
104
51
105
- MongoDB supports text search for various languages. See
52
+ MongoDB also supports text search for various languages. See
106
53
:doc:`/reference/text-search-languages` for a list of supported
107
54
languages.
108
55
109
- .. include:: /includes/fact-atlas-search-languages.rst
110
-
111
56
.. toctree::
112
57
:titlesonly:
113
58
:hidden:
0 commit comments