whitesiroi
whitesiroi

Reputation: 2853

How to Match Against all words except those in parentheses? [MySQL]

I have this query that gives me ids if the word test is exists.

SELECT `Topic`.`id`
FROM `topics` Topic
WHERE MATCH(`Topic`.`title`,`Topic`.`body`) AGAINST('+test' IN BOOLEAN MODE)

Is there a way to filter it somehow? I need to get only ids where the word test is not in parentheses. For example, if we have:

id   text
1    some text test some text
2    some text (test) some text
3    some text (text test text) some text
4    test some text

Is there a way I can get only 1-st and 4-th ids by using Match Against?

Upvotes: 0

Views: 222

Answers (1)

Shadow
Shadow

Reputation: 34284

No, this cannot be achieved through fulltext search, since this would require the search to be aware of a word's context, but fulltext indexes index words only. Perhaps you can do it with regular expressions (rlike operator), but not with fulltext search.

Upvotes: 1

Related Questions