Skip to content

Conversation

@kakao-jenna-me
Copy link

Background

In the MeCab full-text parser documentation, it is described that:

  • In NATURAL LANGUAGE MODE, the search term is converted into a union of tokens.
  • In BOOLEAN MODE, the search term is converted into a search phrase.

However, when using the MeCab plugin, phrase search behavior in BOOLEAN MODE was not enforced correctly: rows were returned even when extra tokens existed between phrase tokens.

--boolean mode
select * from issue_test where match (content) against ('서울날씨' in boolean mode);
+----+-----------------+
| id | content         |
+----+-----------------+
|  1 | 서울날씨        |
|  2 | 서울봄날씨      |
+----+-----------------+

select * from issue_test where match (content) against ('"서울날씨"' in boolean mode);
+----+-----------------+
| id | content         |
+----+-----------------+
|  1 | 서울날씨        |
|  2 | 서울봄날씨      |
+----+-----------------+

--natural mode
select * from issue_test where match (content) against ('서울날씨');
+----+-----------------+
| id | content         |
+----+-----------------+
|  1 | 서울날씨        |
|  2 | 서울봄날씨      |
+----+-----------------+

CAUSE

fts_query_match_phrase_add_word_for_parser() returns a non-zero value when phrase token matching fails.
However, as-is code ignored this return values.

AFTER FIX

--boolean mode
select * from issue_test where match (content) against ('서울날씨' in boolean mode);
+----+--------------+
| id | content      |
+----+--------------+
|  1 | 서울날씨     |
+----+--------------+

select * from issue_test where match (content) against ('"서울날씨"' in boolean mode);
+----+--------------+
| id | content      |
+----+--------------+
|  1 | 서울날씨     |
+----+--------------+

-- natural mode
select * from issue_test where match (content) against ('서울날씨');
+----+-----------------+
| id | content         |
+----+-----------------+
|  1 | 서울날씨        |
|  2 | 서울봄날씨      |
+----+-----------------+

@kakao-jenna-me kakao-jenna-me changed the title fix: ensure performs phrase search in BOOLEAN MODE PS-10383 [8.4]: ensure performs phrase search in BOOLEAN MODE with Mecab plugin Dec 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant