Home > Mobile >  What is the maximum number of words allowed in MySQL 5.7
What is the maximum number of words allowed in MySQL 5.7

Time:04-06

This SELECT(A) will result in an Too many words in a FTS phrase or proximity search error.

I don't want to get an error even with a long sentence, what should I do?

CREATE TABLE my_sentences (
    ID       BIGINT(20)    UNSIGNED NOT NULL AUTO_INCREMENT,
    sentence VARCHAR(8000) NOT NULL,
    PRIMARY KEY (ID),
    FULLTEXT full_my_sentences (sentence) WITH PARSER ngram);

INSERT INTO my_sentences ( sentence )
VALUES ("hello");
# SELECT(A)
SELECT *
FROM my_sentences 
WHERE MATCH (sentence) AGAINST ('Hanged\"I hung myself today. Hanged? Whatever,the point is I hanged myself today and I’m stillhanging.I feel fine. Just bored. I keep hoping thatsomeone will come home and cut me downbut then I keep remembering that if I knewsomeone like that I wouldn’t be up here. Bitironic, right? Or is that not ironic? I readsomewhere that, like, anything funny is,in some way, ironic. But I don’t know if it\'sfunny or not. I don’t think my brain owns“funny' IN BOOLEAN MODE);

(A) is "Too many words" error, but (B) is not an error even though longaer then (A). I don't understand why?

# SELECT(B)
SELECT *
FROM my_sentences 
WHERE MATCH (sentence) AGAINST ('Good morning. In less than an hour, aircraft from here will join others from around the world. And you will be launching the largest aerial battle in the history of mankind. "Mankind." That word should have new meaning for all of us today. We can\'t be consumed by our petty differences anymore. We will be united in our common interests. Perhaps it\'s fate that today is the Fourth of July, and you will once again be fighting for our freedom...Not from tyranny, oppression, or persecution...but from annihilation. We are fighting for our right to live. To exist. And should we win the day, the Fourth of July will no longer be known as an American holiday, but as the day the world declared in one voice: "We will not go quietly into the night! We will not vanish without a fight!" We\'re going to live on! We\'re going to survive! Today we celebrate our Independence Day!' IN BOOLEAN MODE);

What do you recommend me to do?

CodePudding user response:

Maybe this is the reason:

"

A phrase that is enclosed within double quote (") characters matches only rows that contain the phrase literally, as it was typed. The full-text engine splits the phrase into words and performs a search in the FULLTEXT index for the words. Nonword characters need not be matched exactly: Phrase searching requires only that matches contain exactly the same words as the phrase and in the same order. For example, "test phrase" matches "test, phrase".

If the phrase contains no words that are in the index, the result is empty. The words might not be in the index because of a combination of factors: if they do not exist in the text, are stopwords, or are shorter than the minimum length of indexed words.

THIS IS FROM THE LINK FROM @M.HEMANT

  • Related