简体   繁体   English

mysql匹配查询

[英]mysql match against query

I am using mysql match against query in my search query like this way 我在搜索查询中使用mysql匹配查询,就像这样

MATCH(film_name) AGAINST ('the vacation' IN BOOLEAN MODE).

But previously i use this one 但以前我用这个

film_name like '%the vacation%'

So my question is that i am getting the right result now by using match and against but the problem is that when i am using like there i can use the % sign before and after the search string so if the search string present with in the string then it was return the result so plz tell how to write my " MATCH(film_name) AGAINST ('the vacation' IN BOOLEAN MODE) " so that it also behaves `like '%'. 所以我的问题是我现在通过使用匹配和反对来获得正确的结果但问题是,当我在那里使用时,我可以在搜索字符串之前和之后使用%符号,所以如果搜索字符串在字符串中出现然后它返回结果,因此plz告诉我如何编写我的" MATCH(film_name) AGAINST ('the vacation' IN BOOLEAN MODE) "这样它也表现得像'%'。

If the file name is 'rocketsingh' 如果文件名是'rocketsingh'

then if i run film_name like '%rocket%' then it shows me the result 那么如果我film_name like '%rocket%'运行film_name like '%rocket%'那么它会显示结果

but if i run MATCH(film_name) AGAINST ('rocket' IN BOOLEAN MODE) then it will not show any result. 但如果我运行MATCH(film_name) AGAINST ('rocket' IN BOOLEAN MODE)那么它将不会显示任何结果。 Please suggest what to do. 请建议做什么。

MATCH command allows only prefixed wildcards but not postfixed wilcards. MATCH命令仅允许带前缀的通配符,但不允许带有后缀的wilcards。 Since single words are indexed, a postfix wildcard is impossible to manage in the usual way index does. 由于单个单词被索引,因此无法以通常的方式管理后缀通配符。 You can't retrieve *vacation instantly from index because left characters are the most important part of index. 您无法立即从索引中检索*假期 ,因为左侧字符是索引中最重要的部分。

The answer is: You can't. 答案是:你做不到。 The MATCH AGAINST operator matches words, not strings. MATCH AGAINST运算符匹配单词,而不是字符串。 There is a difference between the two. 两者之间存在差异。 Also note that your example will also match vacation , the , vacation the or the something something vacation and other. 还要注意的是你的榜样也将匹配vacationthevacation thethe something something vacation等。 You should read here what searches you can do. 您应该在这里阅读您可以进行的搜索。

You should stick to your first option with LIKE if you don't want word searches. 如果你不想进行单词搜索,你应该坚持使用LIKE的第一个选项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM