如何使用“或”进行搜索狮身人面像中的条款?

发布于 2024-10-20 02:52:58 字数 1567 浏览 4 评论 0原文

我使用 sphinx 有以下索引:

source src1
{
    type                    = mysql
    sql_host        = localhost
    sql_user        = ...
    sql_pass        = ...
    sql_db          = ....
    sql_port        = 3306  # optional, default is 3306
    sql_sock                =  /var/run/mysqld/mysqld.sock

    sql_query       = \
        SELECT anuncio_id,data_criacao,titulo,descricao,categoria1_titulo,categoria1_id,categoria2_titulo,categoria2_id,categoria3_titulo,categoria3_id,categoria4_titulo,categoria4_id FROM ccsprool_indice

    sql_field_string = titulo
    sql_field_string = descricao
    sql_field_string = categoria1_titulo
    sql_field_string = categoria2_titulo
    sql_field_string = categoria3_titulo
    sql_field_string = categoria4_titulo
    sql_attr_uint = categoria1_id
    sql_attr_uint = categoria2_id
    sql_attr_uint = categoria3_id
    sql_attr_uint = categoria4_id
    sql_attr_timestamp = data_criacao        
    sql_query_info          = SELECT * FROM ccsprool_indice WHERE anuncio_id=$id

}

index produtos_sprool
{
    source          = src1
    path            = /usr/local/sphinx/var/data/produtos_sprool
    docinfo         = extern
    mlock           = 0
    morphology      = none
    charset_type        = utf-8
    html_strip       = 1 
    min_word_len            = 3
    min_prefix_len          = 0
    min_infix_len           = 3
    wordforms = /usr/local/sphinx/data/wordforms.txt
}

我需要检查某个项目是否在 categoria1_id、categoria2_id、categoria3_id 或 categoria4_id 中,

我可以使用 Sphinx 执行此操作吗?

I have the following index with sphinx :

source src1
{
    type                    = mysql
    sql_host        = localhost
    sql_user        = ...
    sql_pass        = ...
    sql_db          = ....
    sql_port        = 3306  # optional, default is 3306
    sql_sock                =  /var/run/mysqld/mysqld.sock

    sql_query       = \
        SELECT anuncio_id,data_criacao,titulo,descricao,categoria1_titulo,categoria1_id,categoria2_titulo,categoria2_id,categoria3_titulo,categoria3_id,categoria4_titulo,categoria4_id FROM ccsprool_indice

    sql_field_string = titulo
    sql_field_string = descricao
    sql_field_string = categoria1_titulo
    sql_field_string = categoria2_titulo
    sql_field_string = categoria3_titulo
    sql_field_string = categoria4_titulo
    sql_attr_uint = categoria1_id
    sql_attr_uint = categoria2_id
    sql_attr_uint = categoria3_id
    sql_attr_uint = categoria4_id
    sql_attr_timestamp = data_criacao        
    sql_query_info          = SELECT * FROM ccsprool_indice WHERE anuncio_id=$id

}

index produtos_sprool
{
    source          = src1
    path            = /usr/local/sphinx/var/data/produtos_sprool
    docinfo         = extern
    mlock           = 0
    morphology      = none
    charset_type        = utf-8
    html_strip       = 1 
    min_word_len            = 3
    min_prefix_len          = 0
    min_infix_len           = 3
    wordforms = /usr/local/sphinx/data/wordforms.txt
}

I need to check if an item is in categoria1_id, or categoria2_id, categoria3_id, or categoria4_id

can I do that with Sphinx ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

过潦 2024-10-27 02:52:58

如果我正确理解了任务,这应该有帮助:

$cl->SetSelect('*, categoria1_id=N or categoria2_id=N or categoria3_id=N or categoria4_id=N as fil');
$cl->SetFilter('fil', array(1));

这将返回 categoria1_id/categoria2_id/categoria3_id/categoria4_id 之一设置为 N 的所有文档。

If I understood the task correctly this should help:

$cl->SetSelect('*, categoria1_id=N or categoria2_id=N or categoria3_id=N or categoria4_id=N as fil');
$cl->SetFilter('fil', array(1));

This will return all documents that have one of categoria1_id/categoria2_id/categoria3_id/categoria4_id set to N.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文