1. <small id='ak14V'></small><noframes id='ak14V'>

    2. <tfoot id='ak14V'></tfoot>

      <i id='ak14V'><tr id='ak14V'><dt id='ak14V'><q id='ak14V'><span id='ak14V'><b id='ak14V'><form id='ak14V'><ins id='ak14V'></ins><ul id='ak14V'></ul><sub id='ak14V'></sub></form><legend id='ak14V'></legend><bdo id='ak14V'><pre id='ak14V'><center id='ak14V'></center></pre></bdo></b><th id='ak14V'></th></span></q></dt></tr></i><div id='ak14V'><tfoot id='ak14V'></tfoot><dl id='ak14V'><fieldset id='ak14V'></fieldset></dl></div>
      • <bdo id='ak14V'></bdo><ul id='ak14V'></ul>

        <legend id='ak14V'><style id='ak14V'><dir id='ak14V'><q id='ak14V'></q></dir></style></legend>
      1. 如何允许在搜索查询中使用连字符进行全文搜索

        How to allow fulltext searching with hyphens in the search query(如何允许在搜索查询中使用连字符进行全文搜索)
          • <i id='w4KkA'><tr id='w4KkA'><dt id='w4KkA'><q id='w4KkA'><span id='w4KkA'><b id='w4KkA'><form id='w4KkA'><ins id='w4KkA'></ins><ul id='w4KkA'></ul><sub id='w4KkA'></sub></form><legend id='w4KkA'></legend><bdo id='w4KkA'><pre id='w4KkA'><center id='w4KkA'></center></pre></bdo></b><th id='w4KkA'></th></span></q></dt></tr></i><div id='w4KkA'><tfoot id='w4KkA'></tfoot><dl id='w4KkA'><fieldset id='w4KkA'></fieldset></dl></div>

                <tfoot id='w4KkA'></tfoot>
              1. <small id='w4KkA'></small><noframes id='w4KkA'>

                • <bdo id='w4KkA'></bdo><ul id='w4KkA'></ul>

                • <legend id='w4KkA'><style id='w4KkA'><dir id='w4KkA'><q id='w4KkA'></q></dir></style></legend>

                    <tbody id='w4KkA'></tbody>
                  本文介绍了如何允许在搜索查询中使用连字符进行全文搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有诸如some-or-other"之类的关键字,其中连字符在通过我的 mysql 数据库进行搜索时很重要.我目前正在使用全文功能.

                  I have keywords like "some-or-other" where the hyphens matter in the search through my mysql database. I'm currently using the fulltext function.

                  有没有办法转义连字符?我知道一种选择是在 myisam/ftdefs.h 文件中注释掉 #define HYPHEN_IS_DELIM,但不幸的是我的主机不允许这样做.还有其他选择吗?

                  Is there a way to escape the hyphen character? I know that one option is to comment out #define HYPHEN_IS_DELIM in the myisam/ftdefs.h file, but unfortunately my host does not allow this. Is there another option out there?

                  编辑 3-8-11这是我现在拥有的代码:

                  Edit 3-8-11 Here's the code I have right now:

                  $search_input = $_GET['search_input'];
                  $keyword_safe = mysql_real_escape_string($search_input);
                  $keyword_safe_fix = "*'"" . $keyword_safe . ""'*";
                  
                  
                  $sql = "
                      SELECT *,
                          MATCH(coln1, coln2, coln3) AGAINST('$keyword_safe_fix') AS score
                          FROM table_name
                      WHERE MATCH(coln1, coln2, coln3) AGAINST('$keyword_safe_fix')
                      ORDER BY score DESC
                  ";
                  

                  推荐答案

                  从这里 http://dev.mysql.com/doc/refman/5.0/en/fulltext-search.html

                  查找带有破折号或连字符的单词的一种解决方案是使用布尔模式中的全文搜索,并将带有连字符/破折号的单词用双引号括起来.

                  One solution to find a word with a dashes or hyphens in is to use FULL TEXT SEARCH IN BOOLEAN MODE, and to enclose the word with the hyphen / dash in double quotes.

                  或者从这里http://bugs.mysql.com/bug.php?id=2095

                  还有另一种解决方法.它最近添加到手册中:"修改字符集文件:这不需要重新编译.true_word_char() 宏使用字符类型"表来区分字母和数字人物..您可以在其中一种字符集 XML 中编辑内容文件来指定-"是一个字母".然后使用给定的字符集为您全文索引."

                  There is another workaround. It was recently added to the manual: " Modify a character set file: This requires no recompilation. The true_word_char() macro uses a "character type" table to distinguish letters and numbers from other characters. . You can edit the contents in one of the character set XML files to specify that '-' is a "letter." Then use the given character set for your FULLTEXT indexes. "

                  我自己没有尝试过.

                  这里有更多附加信息 http://dev.mysql.com/doc/refman/5.0/en/fulltext-boolean.html

                  包含在双引号 ("") 字符中的短语仅匹配字面上包含该短语的行,因为它是键入的.全文引擎将短语拆分为单词并在 FULLTEXT 索引中执行搜索单词.在 MySQL 5.0.3 之前,引擎然后对找到的记录中的短语执行子字符串搜索,因此匹配必须包含短语中的非单词字符.从 MySQL 5.0.3 开始,不需要非单词字符完全匹配:短语搜索只要求匹配包含与短语完全相同的单词,并且顺序相同.例如,测试短语"匹配 MySQL 5.0.3 中的测试,短语",但不匹配之前.

                  A phrase that is enclosed within double quote (""") characters matches only rows that contain the phrase literally, as it was typed. The full-text engine splits the phrase into words and performs a search in the FULLTEXT index for the words. Prior to MySQL 5.0.3, the engine then performed a substring search for the phrase in the records that were found, so the match must include nonword characters in the phrase. As of MySQL 5.0.3, nonword characters need not be matched exactly: Phrase searching requires only that matches contain exactly the same words as the phrase and in the same order. For example, "test phrase" matches "test, phrase" in MySQL 5.0.3, but not before.

                  如果短语不包含索引中的单词,则结果为空.例如,如果所有单词都是停用词或短于索引词的最小长度,则结果为空.

                  If the phrase contains no words that are in the index, the result is empty. For example, if all words are either stopwords or shorter than the minimum length of indexed words, the result is empty.

                  这篇关于如何允许在搜索查询中使用连字符进行全文搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Set the variable result, from query(设置变量结果,来自查询)
                  What is dynamic SQL?(什么是动态 SQL?)
                  Mysql - How to quit/exit from stored procedure(Mysql - 如何退出/退出存储过程)
                  Does MySQL have time-based triggers?(MySQL 有基于时间的触发器吗?)
                  is it possible to call a sql script from a stored procedure in another sql script?(是否可以从另一个 sql 脚本中的存储过程调用 sql 脚本?)
                  Procedure to loop through comma separated string is not working(遍历逗号分隔字符串的过程不起作用)
                  • <legend id='yjKhE'><style id='yjKhE'><dir id='yjKhE'><q id='yjKhE'></q></dir></style></legend>
                          <tbody id='yjKhE'></tbody>

                        <small id='yjKhE'></small><noframes id='yjKhE'>

                        <tfoot id='yjKhE'></tfoot>

                            <bdo id='yjKhE'></bdo><ul id='yjKhE'></ul>
                            <i id='yjKhE'><tr id='yjKhE'><dt id='yjKhE'><q id='yjKhE'><span id='yjKhE'><b id='yjKhE'><form id='yjKhE'><ins id='yjKhE'></ins><ul id='yjKhE'></ul><sub id='yjKhE'></sub></form><legend id='yjKhE'></legend><bdo id='yjKhE'><pre id='yjKhE'><center id='yjKhE'></center></pre></bdo></b><th id='yjKhE'></th></span></q></dt></tr></i><div id='yjKhE'><tfoot id='yjKhE'></tfoot><dl id='yjKhE'><fieldset id='yjKhE'></fieldset></dl></div>