Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
MySql全文搜索,包含多个包含/以单词开头/以单词结尾或部分匹配单词_Mysql_Search_Full Text Search - Fatal编程技术网

MySql全文搜索,包含多个包含/以单词开头/以单词结尾或部分匹配单词

MySql全文搜索,包含多个包含/以单词开头/以单词结尾或部分匹配单词,mysql,search,full-text-search,Mysql,Search,Full Text Search,每个人 我正在使用MySQL数据库,并且面临全文搜索的问题。我把桌子换成了MyISAM 这是我的问题 $inputwords=" balu text ama som" (// input words by user in a single input box) $result=SELECT * FROM my table Where MATCH (data, remark, purpose) AGAINST ('$inputwords' IN BOOLEAN MODE); 它为所有行提供与任何

每个人

我正在使用MySQL数据库,并且面临全文搜索的问题。我把桌子换成了MyISAM

这是我的问题

$inputwords=" balu text ama som" (// input words by user in a single input box)
$result=SELECT * FROM my table Where MATCH (data, remark, purpose) AGAINST ('$inputwords' IN BOOLEAN MODE);
它为所有行提供与任何输入字的精确匹配

  • 我的要求是“巴鲁”-巴鲁、巴鲁赛、霍特巴鲁等。所有其他单词都一样,比如通配符
  • 我再次要求只包含上面部分相同的所有单词的行

  • 任何帮助…请。

    要获得
    LIKE
    行为的全文
    匹配()
    ,您必须使用
    *
    ,这相当于使用
    %
    作为LIKE。这样做的目的是让整个字符串如下所示:

    $inputWords = "*balu* *text* *ama* *som*";
    
    代码如下:

    $inputWords = "balu text ama som"; // input words by user in a single input box
    
    // Create array of words by splitting with space char
    $keywords = explode(" ", $inputWords);
    
    $words = '';
    
    foreach($keywords as $key => $value) {
        // concatenate all words following by space, and add * at start and end of the word
        $words .= '*'.$value.'*';
    
        // add space only if it is not the last word
        if($key < count($keywords) - 1)
            $words .= ' ';
    }
    
    “巴鲁”一词将与巴鲁克、巴鲁沙、霍特巴鲁相匹配


    我不知道它是如何降低性能的,但它仍然比我的服务器中的
    类“%word%”
    快得多。

    要获得
    行为的全文
    匹配()
    ,必须使用
    *
    进行匹配,这相当于使用
    %
    进行匹配。这样做的目的是让整个字符串如下所示:

    $inputWords = "*balu* *text* *ama* *som*";
    
    代码如下:

    $inputWords = "balu text ama som"; // input words by user in a single input box
    
    // Create array of words by splitting with space char
    $keywords = explode(" ", $inputWords);
    
    $words = '';
    
    foreach($keywords as $key => $value) {
        // concatenate all words following by space, and add * at start and end of the word
        $words .= '*'.$value.'*';
    
        // add space only if it is not the last word
        if($key < count($keywords) - 1)
            $words .= ' ';
    }
    
    “巴鲁”一词将与巴鲁克、巴鲁沙、霍特巴鲁相匹配


    我不知道它是如何降低性能的,但它仍然比我的服务器中的
    如“%word%”
    快得多。

    *只作为截断运算符工作,因此它是一个“从开始”;它不能执行“以结尾”,所以像“对”(“*text”)这样的匹配不能执行work@lunadir对的但在MyISAM中,自然语言模式下的默认全文搜索将与50%或更多表行中的单词不匹配。因此,要么传递到InnoDB引擎,要么使用布尔模式下的全文作为此回退。是的,我没有注意到MyISAM部分*仅用作截断运算符,因此它是一个“以开始”;它不能执行“以结尾”,所以像“对”(“*text”)这样的匹配不能执行work@lunadir对的但在MyISAM中,自然语言模式下的默认全文搜索将与50%或更多表行中的单词不匹配。因此,要么传递到InnoDB引擎,要么使用布尔模式下的全文作为回退。是的,我没有注意到MyISAM部分