Skip to content

Incorrect Information on MySQL Full-Text Search with Minus Operator #5579

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
Apr 18, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,15 @@ Here's how the following queries would match that text:
| `+fox +dog` | Yes | The text contains 'fox' and 'dog' |
| `+dog +fox` | Yes | The text contains 'dog' and 'fox' |
| `+dog -cat` | Yes | The text contains 'dog' but not 'cat' |
| `-cat` | Yes | 'cat' is not in the text |
| `-cat` | No | The minus operator cannot be used on its own (see note below) |
| `fox dog` | Yes | The text contains 'fox' or 'dog' |
| `-cat -pig` | No | The text does not contain 'cat' or 'pig' |
| `quic*` | Yes | The text contains a word starting with 'quic' |
| `quick fox @2` | Yes | 'fox' starts within a 2 word distance of 'quick' |
| `fox dog @2` | No | 'dog' does not start within a 2 word distance of 'fox' |
| `"jumps over"` | Yes | The text contains the whole phrase 'jumps over' |

> **Note**: The - operator acts only to exclude rows that are otherwise matched by other search terms. Thus, a boolean-mode search that contains only terms preceded by - returns an empty result. It does not return “all rows except those containing any of the excluded terms.”

MySQL also has `>`, `<` and `~` operators for altering the ranking order of search results. As an example, consider the following two records:

**1. "The quick brown fox jumps over the lazy dog"**
Expand Down