Mysql - 使用入门 (9)

查询扩展用来放宽所返回的文本搜索结果的范围

在使用查询扩展的时候Mysql对数据和索引进行两边扫描完成搜索

-- 在在上的例子中没有使用查询扩展的时候只能返回两行 -- 现在使用返回了6行 select note_text from productnotes where Match(note_text) Against('rabbit' with query expansion)\G; *************************** 1. row *************************** note_text: Quantity varies, sold by the sack load. All guaranteed to be bright and orange, and suitable for use as rabbit bait. *************************** 2. row *************************** note_text: Customer complaint: rabbit has been able to detect trap, food apparently less effective now. *************************** 3. row *************************** note_text: Customer complaint: Circular hole in safe floor can apparently be easily cut with handsaw. *************************** 4. row *************************** note_text: Customer complaint: Sticks not individually wrapped, too easy to mistakenly detonate all at once. Recommend individual wrapping. *************************** 5. row *************************** note_text: Customer complaint: Not heavy enough to generate flying stars around head of victim. If being purchased for dropping, recommend ANV02 or ANV03 instead. *************************** 6. row *************************** note_text: Multiple customer returns, anvils failing to drop fast enough or falling backwards on purchaser. Recommend that customer considers using heavier anvils. 6 rows in set (0.00 sec) 14.4布尔文本搜索 in boolean mode

即使没有定义fulltext索引,也可以使用它哟

select note_text from productnotes where Match(note_text) Against('rabbit' in boolean mode) \G; *************************** 1. row *************************** note_text: Quantity varies, sold by the sack load. All guaranteed to be bright and orange, and suitable for use as rabbit bait. *************************** 2. row *************************** note_text: Customer complaint: rabbit has been able to detect trap, food apparently less effective now. 2 rows in set (0.00 sec) -- 匹配包含 heavy 但不包含任意一repo开始的词 select note_text from productnotes where Match(note_text) Against('heavy -rope*' in boo lean mode) \G; *************************** 1. row *************************** note_text: Customer complaint: Not heavy enough to generate flying stars around head of victim. If being purchased for dropping, recommend ANV02 or ANV03 instead. 1 row in set (0.01 sec)

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wpzyzd.html