【问题标题】:Sphinx - combine OR operator with field start/end modifierSphinx - 将 OR 运算符与字段开始/结束修饰符组合
【发布时间】:2018-10-01 09:40:05
【问题描述】:

这个表达式写对了吗?因为我没有收到预期的所有结果:

(@nationality_code ("^MD$" | "^GB$" | "^IT$"))

我应该让所有国籍代码等于“MD”或“GB”或“IT”的用户

在mysql中应该是这样的查询:

SELECT * FROM users WHERE nationality_code IN ('MD', 'GB', 'IT')

更新 如果我只搜索 MD 和 GB,我会收到正确的结果:

我执行的查询是这样的:

SELECT id, nationality_code 
FROM jobs_applied_main 
WHERE MATCH('(@nationality_code ("^MD$" | "^GB$"))') AND job_id = '6257' 
LIMIT 0, 999;

但如果我还添加“^IT$”,我将不再获得国籍为“MD”的用户。

如果我删除开始/结束修饰符,我会收到预期的结果,为什么会出现这种行为?

更新 所以,这里是我的索引转储和 sphinx.conf 文件:sphinx-dump

【问题讨论】:

    标签: php full-text-search sphinx


    【解决方案1】:

    是的。表达是对的。它对我来说很好用:

    [snikolaev@dev01 ~]$ mysql -P9314 -h0
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 1
    Server version: 2.7.1 668faae@180620 dev
    
    Copyright (c) 2009-2017 Percona LLC and/or its affiliates
    Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
    
    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.
    
    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
    
    mysql> select * from idx_min where match('(@nationality_code ("^MD$" | "^GB$" | "^IT$"))');
    +------+------------------+------+
    | id   | nationality_code | a    |
    +------+------------------+------+
    |    1 | MD               |  123 |
    |    2 | GB               |  123 |
    +------+------------------+------+
    2 rows in set (0.00 sec)
    

    确保您在索引中确实只有 MD/GB/IT,之前/之后没有任何内容,并且您没有 min_word_len

    【讨论】:

    • 谢谢,问题是我有 min_word_len min_word_len = 1 min_infix_len = 2 min_prefix_len = 1 expand_keywords = 1 那么正确的配置是什么?
    • @Mintendo 对不起,我的意思是你没有 min_word_len > 2(不是
    • 好的,我添加了我的问题的更新,你能检查一下吗?无论如何,我的狮身人面像版本是 3.0.3-dev
    • @Mintendo 在 3.0.3 中仍然为我工作。如果您提供配置以及如何重现索引(--dump-rows 或仅索引文件)会更容易
    • 好的,我在wetransfer中上传了sphinx.conf并提供了上面的链接
    【解决方案2】:

    Sphinx 3.0.3 版本存在问题,因为 Sphinx 2.2.11 可以正常工作

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-05-09
      • 2020-12-17
      • 2021-07-19
      • 2019-11-12
      • 2018-07-24
      • 2022-01-25
      • 1970-01-01
      相关资源
      最近更新 更多