@@ -25,6 +25,45 @@ The text search process:
25
25
By default, :dbcommand:`text` command returns at most the top 100
26
26
matching documents as determined by the scores.
27
27
28
+ .. important::
29
+
30
+ Before you can create a text index or :ref:`run the text command
31
+ <text-search-text-command>`, you need to manually enable the text
32
+ search. See :doc:`/tutorial/enable-text-search` for information on
33
+ how to enable the text search feature.
34
+
35
+ .. _text-search-storage-requirements:
36
+
37
+ Storage Requirements and Performance Costs
38
+ ------------------------------------------
39
+
40
+ ``text`` indexes have the following storage requirements and
41
+ performance costs:
42
+
43
+ - ``text`` indexes change the space allocation method for all future
44
+ record allocations in a collection to :collflag:`usePowerOf2Sizes`.
45
+
46
+ - ``text`` indexes can be large. They contain one index entry for each
47
+ unique post-stemmed word in each indexed field for each document
48
+ inserted.
49
+
50
+ - Building a ``text`` index is very similar to building a large
51
+ multi-key index and will take longer than building a simple ordered
52
+ (scalar) index on the same data.
53
+
54
+ - When building a large ``text`` index on an existing collection,
55
+ ensure that you have a sufficiently high limit on open file
56
+ descriptors. See the :ref:`recommended settings <oom-killer>`.
57
+
58
+ - ``text`` indexes will impact insertion throughput because MongoDB
59
+ must add an index entry for each unique post-stemmed word in each
60
+ indexed field of each new source document.
61
+
62
+ - Additionally, ``text`` indexes do not store phrases or information
63
+ about the proximity of words in the documents. As a result, phrase
64
+ queries will run much more effectively when the entire collection
65
+ fits in RAM.
66
+
28
67
.. _create-text-index:
29
68
30
69
Create a ``text`` Index
@@ -38,36 +77,24 @@ the string literal ``text``.
38
77
39
78
.. important::
40
79
41
- - Before you can :ref:`create a text index <create-text-index>` or
42
- :ref:`run the text command <text-search-text-command>`, you need
43
- to manually enable the text search. See
44
- :doc:`/tutorial/enable-text-search` for information on how to
45
- enable the text search feature.
46
-
47
80
- Text indexes have significant storage requirements and performance
48
- costs. See :ref:`text index feature <index-feature-text> ` for more
81
+ costs. See :ref:`text-search-storage-requirements ` for more
49
82
information.
50
83
51
84
- .. include:: /includes/fact-text-index-limit-one.rst
52
85
53
- The following example creates a ``text`` index on the fields
54
- ``subject`` and ``content``:
86
+ The following tutorials offer additional ``text`` index creation
87
+ patterns:
88
+
89
+ - :doc:`/tutorial/create-text-index-on-multiple-fields`
55
90
56
- .. code-block:: javascript
91
+ - :doc:`/tutorial/specify-language-for-text-index`
57
92
58
- db.collection.ensureIndex(
59
- {
60
- subject: "text",
61
- content: "text"
62
- }
63
- )
93
+ - :doc:`/tutorial/avoid-text-index-name-limit`
64
94
65
- This ``text`` index catalogs all string data in the ``subject`` field
66
- and the ``content`` field, where the field value is either a string or
67
- an array of string elements.
95
+ - :doc:`/tutorial/create-text-index-on-multi-language-collection`
68
96
69
- See :doc:`/core/text-indexes` for details on the options available when
70
- creating ``text`` indexes.
97
+ - :doc:`/tutorial/control-results-of-text-search`
71
98
72
99
Additionally, MongoDB permits :ref:`compound indexes
73
100
<index-type-compound>` that include ``text`` index fields in
@@ -89,18 +116,6 @@ document field contains the word ``blueberry``, a search on the term
89
116
``blue`` will not match the document. However, a search on either
90
117
``blueberry`` or ``blueberries`` will match.
91
118
92
- By default, the :dbcommand:`text` command returns the top 100 scoring
93
- documents in descending order, but you can specify a ``limit`` option
94
- to change the maximum number to return.
95
-
96
- Given a collection with a ``text`` index, use the
97
- :method:`~db.runCommand()` method to execute the
98
- :dbcommand:`text` command, as in:
99
-
100
- .. code-block:: javascript
101
-
102
- db.collection.runCommand( "text" , { search: <string> } )
103
-
104
119
For information and examples on various text search patterns, see
105
120
:doc:`/tutorial/search-for-text`.
106
121
0 commit comments