是否有可能在mysql的全文搜索中搜索整个给定的单词 [英] Is it possible to search for whole given word in Full text search of mysql

查看:206
本文介绍了是否有可能在mysql的全文搜索中搜索整个给定的单词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在3列使用全文搜索和mysql。假设数据如下:


  1. Row1包含两列,分别是'大诺伊达高速公路'和'部门91'。

  2. Row2包含两列,分别是'Ho Chi Minh Marg'和'Greater Kailash 2'。

  3. Row3包含两列'Rohini'和'Sector 91' b

    $ b现在,如果我用

    查询

      SELECT * FROM trafficker.traffics WHERE MATCH(column1,column2)AGAINST('Greater Noida'); 

    上面的查询会产生前两行,因为匹配会在'Greater'和'Noida' 。 Row2的'Greater Kailash'中还会出现'Greater':|

    有什么方法可以阻止对'空间'的搜索并将大诺伊达视为一个搜索短语,而不是'空格'分隔??

    这将是非常有用的,因为它会帮助我过滤噪声,因为实际数据将是非常巨大的

    感谢您的提前!

    编辑:
    另问题是如果我搜索Sector 91,它只会搜索Sector并忽略91(因为它少于四个字符)。有什么办法可以解决这个问题,而不是下载源代码并编译它。因为我确信它不能在共享服务器上工作:(


    解决方案

    检查'in boolean mode'选项:



    http: //dev.mysql.com/doc/refman/5.5/en/fulltext-boolean.html



    你可以用单引号括住单词,如:



    pre $ SELECT * FROM trafficker.traffics WHERE MATCH(column1,column2)AGAINST(''Greater Noida''IN BOOLEAN MODE);

    这应该让你接近你想要的。


    I am using Full Text Search with mysql on 3 columns. Assume data like:

    1. Row1 contain two columns with 'Greater Noida Expressway' and 'Sector 91'.
    2. Row2 contain two columns with 'Ho Chi Minh Marg' and 'Greater Kailash 2'.
    3. Row3 contain two columns with 'Rohini' and 'Sector 91'

    Now, if I query with

    SELECT * FROM trafficker.traffics WHERE MATCH (column1, column2) AGAINST ('Greater Noida'); 
    

    Above query will result me first two rows as matching will be done on 'Greater' and 'Noida'. And 'Greater' will also be found in 'Greater Kailash' of Row2 :|

    Is there any way I can block the search on 'space' and consider Greater Noida as one search phrase and not separated by 'space'??

    This will be very useful as it will help me in filtering the noise as actual data is going to be very huge..

    Thanks in advance!

    Edit: Another problem is that if I search for Sector 91. It will only search for Sector and will ignore 91(as this is less than four characters). Is there any way to resolve this other than downloading the source code and compiling the same. Because I am sure it won't work on shared server :(

    解决方案

    Check the 'in boolean mode' option:

    http://dev.mysql.com/doc/refman/5.5/en/fulltext-boolean.html

    You can wrap the words in quotes, like:

    SELECT * FROM trafficker.traffics WHERE MATCH (column1, column2) AGAINST ('"Greater Noida"' IN BOOLEAN MODE); 
    

    That should get you close to what you want.

    这篇关于是否有可能在mysql的全文搜索中搜索整个给定的单词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆