Skip to content

Commit 279f758

Browse files
committed
DOCS-953 release notes edits to text search info
1 parent 59ed04e commit 279f758

File tree

1 file changed

+87
-65
lines changed

1 file changed

+87
-65
lines changed

source/release-notes/2.4.txt

Lines changed: 87 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -50,28 +50,34 @@ Text Indexes
5050

5151
.. note::
5252

53-
The ``text`` index type is currently an experimental feature and
54-
you must enable it at run time. Interfaces and on-disk format may
55-
change in future releases.
53+
The ``text`` index type is currently an experimental feature.
54+
Interfaces and on-disk format may change in future releases. To use
55+
``text`` index, you need to enable it at run time. Do **not** enable
56+
or use ``text`` indexes on production systems.
5657

5758
Background
5859
``````````
5960

60-
MongoDB2.3.2 includes a new ``text`` index type. ``text`` indexes
61-
support boolean text search queries. Any set of fields containing
62-
string data may be text indexed. You may only maintain a single
63-
``text`` index per collection. ``text`` indexes are fully consistent
64-
and updated in real-time as applications insert, update, or delete
65-
documents from the database. The ``text`` index and query system
66-
supports language specific stemming and stop-words. Additionally:
61+
MongoDB 2.3.2 includes a new ``text`` index type. ``text`` indexes
62+
support boolean text search queries:
6763

68-
- indexes and queries drop stop words (i.e. "the," "an," "a," "and,"
69-
etc.)
64+
- Any set of fields containing string data may be text indexed.
7065

71-
- MongoDB stores words stemmed during insertion in the index, using
72-
simple suffix stemming, including support for a number of
73-
languages. MongoDB automatically stems :dbcommand:`text` queries at
74-
before beginning the query.
66+
- You may only maintain a **single** ``text`` index per collection.
67+
68+
- ``text`` indexes are fully consistent and updated in real-time as
69+
applications insert, update, or delete documents from the database.
70+
71+
- The ``text`` index and query system supports language specific
72+
stemming and stop words. Additionally:
73+
74+
- Indexes and queries drop stop words (i.e. "the," "an," "a," "and,"
75+
etc.)
76+
77+
- MongoDB stores words stemmed during insertion in the index, using
78+
simple suffix stemming, including support for a number of
79+
languages. MongoDB automatically stems :dbcommand:`text` queries at
80+
before beginning the query.
7581

7682
However, ``text`` indexes have large storage requirements and incur
7783
**significant** performance costs:
@@ -81,11 +87,11 @@ However, ``text`` indexes have large storage requirements and incur
8187

8288
- Building a ``text`` index is very similar to building a large
8389
multi-key index, and therefore may take longer than building a
84-
simple ordered (scalar)index.
90+
simple ordered (scalar) index.
8591

8692
- ``text`` indexes will impede insertion throughput, because MongoDB
87-
must add an index entry for each unique word in each indexed field
88-
of each new source document.
93+
must add an index entry for each unique word in each indexed field of
94+
each new source document.
8995

9096
- some :dbcommand:`text` searches may affect performance on your
9197
:program:`mongod`, particularly for negation queries and phrase
@@ -103,11 +109,11 @@ indexes have the following limitations and behaviors:
103109
- MongoDB does not stem phrases or negations in :dbcommand:`text`
104110
queries.
105111

106-
- the index is case insensitive.
112+
- the index is case-insensitive.
107113

108114
- a collection may only have a single ``text`` index at a time.
109115

110-
.. important:: Do not enable or use ``text`` indexes on production
116+
.. important:: Do **not** enable or use ``text`` indexes on production
111117
systems.
112118

113119
.. May be worth including this:
@@ -120,21 +126,25 @@ indexes have the following limitations and behaviors:
120126
Test ``text`` Indexes
121127
`````````````````````
122128

123-
.. important:: The ``text`` index type is an experimental feature and
124-
you must enable the feature before creating or accessing a text
125-
index. To enable text indexes, issue the following command at the
126-
:program:`mongo` shell:
129+
The ``text`` index type is an experimental feature and you need to
130+
enable the feature before creating or accessing a text index.
131+
132+
To enable text indexes, issue the following command in the
133+
:program:`mongo` shell:
127134

128-
.. code-block:: javascript
135+
.. important:: Do **not** enable or use ``text`` indexes on production
136+
systems.
129137

130-
db.adminCommand( { setParameter: 1, textSearchEnabled: true } )
138+
.. code-block:: javascript
131139

132-
You can also start the :program:`mongod` with the following
133-
invocation:
140+
db.adminCommand( { setParameter: 1, textSearchEnabled: true } )
134141

135-
.. code-block:: sh
142+
You can also start the :program:`mongod` with the following
143+
invocation:
136144

137-
mongod --setParameter textSearchEnabled=true
145+
.. code-block:: sh
146+
147+
mongod --setParameter textSearchEnabled=true
138148

139149
Create Text Indexes
140150
^^^^^^^^^^^^^^^^^^^
@@ -157,7 +167,7 @@ and from fields in sub-documents, as in the following:
157167
"users.profiles": "text" } )
158168

159169
The default name for the index consists of the ``<field name>``
160-
concatenated with ``_text``, as in the following:
170+
concatenated with ``_text`` for the indexed fields, as in the following:
161171

162172
.. code-block:: javascript
163173

@@ -193,19 +203,22 @@ sub-documents. Furthermore, the ``content`` field has a weight of 1 and
193203
the ``users.profiles`` field has a weight of 2.
194204

195205
You can add a conventional ascending or descending index field(s) as a
196-
prefix or suffix of the index so that queries can limit the number of
197-
index entries the query must review to perform the query. You cannot
198-
include :ref:`multi-key <index-type-multi-key>` index field nor
199-
:ref:`geospatial <index-feature-geospatial>` index field.
206+
prefix or suffix of the index. You cannot include :ref:`multi-key
207+
<index-type-multi-key>` index field nor :ref:`geospatial
208+
<index-feature-geospatial>` index field.
200209

201210
If you create an ascending or descending index as a prefix of a
202211
``text`` index:
203212

204213
- MongoDB will only index documents that have the prefix field
205214
(i.e. ``username``) and
206215

207-
- All :dbcommand:`text` queries using this index must specify the
208-
prefix field in the ``filter`` query.
216+
- The :dbcommand:`text` query can limit the number of index entries to
217+
review in order to perform the query.
218+
219+
- All :dbcommand:`text` queries using this index must include the
220+
``filter`` option that specifies an equality condition for the prefix
221+
field or fields.
209222

210223
Create this index with the following operation:
211224

@@ -295,8 +308,15 @@ cursor.
295308
:param string search:
296309

297310
A text string that MongoDB stems and uses to query the ``text``
298-
index. When specifying phrase matches, you must escape quote
299-
characters as ``\"``.
311+
index. In the :program:`mongo` shell, to specify a phrase to
312+
match, you can either:
313+
314+
- enclose the phrase in escaped double quote characters
315+
(``\"<phrase>\"``) within the ``search`` string, as in
316+
``"\"coffee table\""``, or
317+
318+
- enclose the phrase in single quote characters, as in ``"'coffee
319+
table'"``
300320

301321
:param document filter:
302322

@@ -318,19 +338,20 @@ cursor.
318338
:param number limit:
319339

320340
Optional. Specify the maximum number of documents to include in
321-
the response.
341+
the response. The default limit is 100.
322342

323343
:param string language:
324344

325345
Optional. Specify the language that determines the tokenization,
326-
stemming, and the stop words for the search.
346+
stemming, and the stop words for the search. The default language
347+
is english.
327348

328349
:return:
329350

330-
:dbcommand:`text` returns results in the form of a
331-
document. Results must fit within the :limit:`BSON Document
332-
Size`. Use a projection setting to limit the size of the result
333-
set.
351+
:dbcommand:`text` returns results in the form of a document.
352+
Results must fit within the :limit:`BSON Document Size`. Use the
353+
``limit`` and the ``projection`` parameters to limit the size of
354+
the result set.
334355

335356
The implicit connector between the terms of a multi-term search is a
336357
disjunction (``OR``). Search for ``"first second"`` searches
@@ -367,20 +388,20 @@ cursor.
367388

368389
db.collection.runCommand( "text", { search: "search" } )
369390

370-
This query returns documents that contain the word
371-
``search``, case-insensitive, in the ``content`` field.
372-
391+
This query returns documents that contain the word ``search``,
392+
case-insensitive, in the ``content`` field.
393+
373394
#. Search for multiple words, ``create`` or ``search`` or ``fields``:
374-
395+
375396
.. code-block:: javascript
376-
397+
377398
db.collection.runCommand( "text", { search: "create search fields" } )
378-
399+
379400
This query returns documents that contain the either ``create``
380401
**or** ``search`` **or** ``field`` in the ``content`` field.
381-
402+
382403
#. Search for the exact phrase ``create search fields``:
383-
404+
384405
.. code-block:: javascript
385406

386407
db.collection.runCommand( "text", { search: "\"create search fields\"" } )
@@ -397,7 +418,7 @@ cursor.
397418

398419
Use the ``-`` as a prefix to terms to specify negation in the
399420
search string. The query returns documents that contain the
400-
either ``creat`` **or** ``search``, but **not** ``field``, all
421+
either ``create`` **or** ``search``, but **not** ``field``, all
401422
case-insensitive, in the ``content`` field. Prefixing a word
402423
with a hyphen (``-``) negates a word:
403424

@@ -407,8 +428,8 @@ cursor.
407428
- A ``<search string>`` that only contains negative words returns no match.
408429

409430
- A hyphenated word, such as ``case-insensitive``, is not a
410-
negation. The :dbcommand:`text` command treats the hyphen and
411-
as a delimiter.
431+
negation. The :dbcommand:`text` command treats the hyphen as a
432+
delimiter.
412433

413434
#. Search for a single word ``search`` with an additional ``filter`` on
414435
the ``about`` field, but **limit** the results to 2 documents with the
@@ -424,16 +445,17 @@ cursor.
424445
projection: { comments: 1, _id: 0 }
425446
}
426447
)
427-
448+
428449
- The ``filter`` :ref:`query document <mongodb-query-document>`
429-
is uses a :operator:`regular expression <$regex>`. See the
430-
:ref:`query operators <operator>` page for available query
450+
uses a :operator:`regular expression <$regex>`. See the
451+
:doc:`query operators </reference/operator>` page for available query
431452
operators.
432-
433-
- The ``projection`` must explicitly exclude (``0``) the ``_id``
434-
field. Within the ``projection`` document, you cannot mix
435-
inclusions (i.e. ``<fieldA>: 1``) and exclusions (i.e. ``<fieldB>:
436-
0``), except for the ``_id`` field.
453+
454+
- Because the ``_id`` field is implicitly included, in order to
455+
return **only** the ``comments`` field, you must explicitly
456+
exclude (``0``) the ``_id`` field. Within the ``projection``
457+
document, you cannot mix inclusions (i.e. ``<fieldA>: 1``) and
458+
exclusions (i.e. ``<fieldB>: 0``), except for the ``_id`` field.
437459

438460
Additional Authentication Features
439461
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

0 commit comments

Comments
 (0)