Skip to content

DOCS-10382: Clarify text search phrase matching behaviour #3517

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions source/reference/operator/query/text.txt
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,7 @@ phrase in escaped double quotes (``\"``), as in:
"\"ssl certificate\""

If the ``$search`` string includes a phrase and individual terms, text
search will only match the documents that include the phrase. More
specifically, the search performs a logical ``AND`` of the phrase with
the individual terms in the search string.
search will only match the documents that include the phrase.

For example, passed a ``$search`` string:

Expand All @@ -118,8 +116,7 @@ For example, passed a ``$search`` string:
"\"ssl certificate\" authority key"

The :query:`$text` operator searches for the phrase ``"ssl
certificate"`` **and** (``"authority"`` **or** ``"key"`` **or**
``"ssl"`` **or** ``"certificate"`` ).
certificate"``.

.. _text-operator-term-negation:

Expand Down
9 changes: 7 additions & 2 deletions source/text-search.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,17 @@ Exact Phrase
````````````

You can also search for exact phrases by wrapping them in double-quotes.
For example, the following will find all documents containing "java" or
If the ``$search`` string includes a phrase and individual terms, text search
will only match documents that include the phrase.

For example, the following will find all documents containing
"coffee shop":

.. code-block:: javascript

db.stores.find( { $text: { $search: "java \"coffee shop\"" } } )
db.stores.find( { $text: { $search: "\"coffee shop\"" } } )

For more information, see :ref:`text-operator-phrases`.

Term Exclusion
``````````````
Expand Down