diff --git a/source/applications/text-search.txt b/source/applications/text-search.txt index 730ca144470..8e8ad29c5bc 100644 --- a/source/applications/text-search.txt +++ b/source/applications/text-search.txt @@ -32,7 +32,7 @@ Create a ``text`` Index To perform text search, create a ``text`` index on the field or fields whose value is a string or an array of string elements. To create a -``text`` indexes, use the :method:`db.collection.ensureIndex()` method +``text`` index, use the :method:`db.collection.ensureIndex()` method with a document that contains field and value pairs where the value is the string literal ``text``. @@ -66,10 +66,10 @@ This ``text`` index catalogs all string data in the ``subject`` field and the ``content`` field, where the field value is either a string or an array of string elements. -See :doc:`/core/text-index` for details on the options available when +See :doc:`/core/text-indexes` for details on the options available when creating ``text`` indexes. -Additionally, ``text`` indexes can also be combined with +Additionally, ``text`` indexes can be combined with ascending/descending index fields. See: - :doc:`/tutorial/limit-number-of-items-scanned-for-text-search` @@ -87,9 +87,9 @@ document field contains the word ``blueberry``, a search on the term ``blue`` will not match the document. However, a search on either ``blueberry`` or ``blueberries`` will match. -By default, the :dbcommand:`text` returns the top 100 scoring documents -in descending order, but you can specify a ``limit`` option to change -the maximum number to return. +By default, the :dbcommand:`text` command returns the top 100 scoring +documents in descending order, but you can specify a ``limit`` option +to change the maximum number to return. Given a collection with a ``text`` index, use the :method:`~db.collection.runCommand()` method to execute the diff --git a/source/core/indexes.txt b/source/core/indexes.txt index 548d3b35594..0c057821e15 100644 --- a/source/core/indexes.txt +++ b/source/core/indexes.txt @@ -789,27 +789,27 @@ MongoDB provides ``text`` indexes to support :doc:`text search ``text`` indexes are case-insensitive and can include any field that contains string data. ``text`` indexes drop language-specific stop -words (e.g. in English, “the,” “an,” “a,” “and,” etc.) and uses simple +words (e.g. in English, "the," "an," "a," "and," etc.) and uses simple language-specific suffix stemming. See :ref:`text-search-languages` for the supported languages. ``text`` indexes have the following storage requirements and performance costs: -- Text indexes change the space allocation method for all future +- ``text`` indexes change the space allocation method for all future record allocations in a collection to :collflag:`usePowerOf2Sizes`. -- Text indexes can be large. They contain one index entry for each +- ``text`` indexes can be large. They contain one index entry for each unique post-stemmed word in each indexed field for each document inserted. - Building a ``text`` index is very similar to building a large - multi-key index, and will take longer than building a simple ordered + multi-key index and will take longer than building a simple ordered (scalar) index on the same data. - When building a large ``text`` index on an existing collection, - ensure that you have a sufficiently-high open file descriptor limit. - See the :ref:`recommended settings `. + ensure that you have a sufficiently high limit on open file + descriptors. See the :ref:`recommended settings `. - ``text`` indexes will impact insertion throughput because MongoDB must add an index entry for each unique post-stemmed word in each diff --git a/source/core/text-indexes.txt b/source/core/text-indexes.txt index 0f0168398b3..11f17f54379 100644 --- a/source/core/text-indexes.txt +++ b/source/core/text-indexes.txt @@ -10,9 +10,10 @@ creating ``text`` indexes. Specify a Name for the ``text`` Index ------------------------------------- -The default name for the index consists of each index field name -concatenated with ``_text``. Consider the ``text`` index on the fields -``content``, ``users.comments``, and ``users.profiles``. +The default name for the index consists of each indexed field name +concatenated with ``_text``. For example, the following command creates +a ``text`` index on the fields ``content``, ``users.comments``, and +``users.profiles``: .. code-block:: javascript @@ -60,7 +61,8 @@ wildcard specifier (``$**``) to index all fields that contain string content. The following example indexes any string value in the data of every -field of every document in a collection and names it ``TextIndex``: +field of every document in ``collection`` and names the index +``TextIndex``: .. code-block:: javascript @@ -104,10 +106,10 @@ Control Results of Text Search with Weights By default, the :dbcommand:`text` command returns matching documents based on scores, from highest to lowest. For a ``text`` index, the -*weight* of an indexed field denote the significance of the field +*weight* of an indexed field denotes the significance of the field relative to the other indexed fields in terms of the score. The score -calculation for a given word in a document includes the weighted sum of -the frequency for each of the indexed fields in that document. +for a given word in a document is derived from the weighted sum of the +frequency for each of the indexed fields in that document. The default weight is 1 for the indexed fields. To adjust the weights for the indexed fields, include the ``weights`` option in the @@ -135,7 +137,9 @@ A collection ``blog`` has the following documents: To create a ``text`` index with different field weights for the ``content`` field and the ``keywords`` field, include the ``weights`` -option to the :method:`~db.collection.ensureIndex()` method. +option to the :method:`~db.collection.ensureIndex()` method. For +example, the following command creates an index on three fields and +assigns weights to two of the fields: .. code-block:: javascript diff --git a/source/includes/fact-text-index-limit-one.rst b/source/includes/fact-text-index-limit-one.rst index f31ee3d2178..ca4a42de78c 100644 --- a/source/includes/fact-text-index-limit-one.rst +++ b/source/includes/fact-text-index-limit-one.rst @@ -1 +1 @@ -A collection can have at most only **one** ``text`` index. \ No newline at end of file +A collection can have at most **one** ``text`` index. \ No newline at end of file diff --git a/source/reference/command/text.txt b/source/reference/command/text.txt index 70c3a6d4b6a..661e19286c7 100644 --- a/source/reference/command/text.txt +++ b/source/reference/command/text.txt @@ -9,7 +9,7 @@ text .. versionadded:: 2.4 The :dbcommand:`text` command provides an interface to search text - context stored in the :ref:`text index `. By + content stored in the :ref:`text index `. By default, the command limits the matches to the top 100 scoring documents, in descending score order, but you can specify a different limit. The :dbcommand:`text` command is @@ -46,7 +46,7 @@ text - The negated word excludes documents that contain the negated word from the result set. - - A search string that only contains negative words returns + - A search string that only contains negated words returns **no** match. - A hyphenated word, such as ``pre-market``, is not a @@ -85,9 +85,10 @@ text Optional. Specify the language that determines for the search the list of stop words and the rules for the stemmer and - tokenizer. If not specified, the search uses default language - of the index. See :ref:`text-search-languages` for the - supported languages. Specify the language in **lowercase**. + tokenizer. If not specified, the search uses the default + language of the index. See :ref:`text-search-languages` for + the supported languages. Specify the language in + **lowercase**. :return: @@ -96,8 +97,10 @@ text order by score. See :ref:`text-search-output` for details. The returned document must fit within the :limit:`BSON - Document Size`. Use the ``limit`` and the ``project`` - parameters to limit the size of the result set. + Document Size`. Otherwise, the command will return as many + results as not to exceed the :limit:`BSON Document Size`. + Use the ``limit`` and the ``project`` parameters to limit + the size of the result set. .. note:: @@ -110,10 +113,10 @@ text logical ``AND`` operator. - The :dbcommand:`text` command ignores stop words for the search - language language, such as ``the`` and ``and`` in English. + language, such as ``the`` and ``and`` in English. - The :dbcommand:`text` command matches on the complete *stemmed* - words. So if a document field contains the word ``blueberry``, + word. So if a document field contains the word ``blueberry``, a search on the term ``blue`` will not match. However, ``blueberry`` or ``blueberries`` will match. @@ -157,7 +160,7 @@ text Use the hyphen (``-``) as a prefix to exclude documents that contain a term. Search for documents that contain the words - ``bake`` or ``coffee``, but does **not** contain ``cake``: + ``bake`` or ``coffee`` but do **not** contain ``cake``: .. code-block:: javascript diff --git a/source/reference/text-search.txt b/source/reference/text-search.txt index 5df79f2b805..31930b5a654 100644 --- a/source/reference/text-search.txt +++ b/source/reference/text-search.txt @@ -15,9 +15,10 @@ example: .. warning:: The complete results of the :dbcommand:`text` command must fit - within the :limit:`BSON Document Size`. Use the ``limit`` and the - ``project`` parameters with the :dbcommand:`text` command to limit - the size of the result set. + within the :limit:`BSON Document Size`. Otherwise, the command will + return as many results as not to exceed the :limit:`BSON Document + Size`. Use the ``limit`` and the ``project`` parameters with the + :dbcommand:`text` command to limit the size of the result set. .. code-block:: javascript