如何在 SPHINX 中获取文本结果

发布于 2024-11-30 15:48:34 字数 914 浏览 3 评论 0原文

我正在尝试使用 Sphinx API 来获取文本结果,我得到的只是这样:

16809 Array (
    [error] =>
    [warning] =>
    [status] => 0
    [fields] => Array (
        [0] => name
        [1] => description
    )
    [attrs] => Array ( )
    [matches] => Array (
        [16809] => Array ( [weight] => 2 [attrs] => Array ( ) )
    )
    [total] => 1
    [total_found] => 1
    [time] => 0.000
    [words] => Array (
        [radell] => Array (
            [docs] => 1
            [hits] => 2
        )
    )
)

我在 sphinx.conf 中使用以下附加行:

sql_query                       = \
            SELECT \
                    id, name, description \
            FROM \
                    products_description;
sql_field_string = name
   sql_query_info = SELECT * FROM products_description WHERE id=$id

是否可以获取名称和描述等完整文本结果,而不是上面的内容大批 ?

I'm trying to use Sphinx API to get the text result all I get is something like this:

16809 Array (
    [error] =>
    [warning] =>
    [status] => 0
    [fields] => Array (
        [0] => name
        [1] => description
    )
    [attrs] => Array ( )
    [matches] => Array (
        [16809] => Array ( [weight] => 2 [attrs] => Array ( ) )
    )
    [total] => 1
    [total_found] => 1
    [time] => 0.000
    [words] => Array (
        [radell] => Array (
            [docs] => 1
            [hits] => 2
        )
    )
)

I'm using the following additional lines in sphinx.conf:

sql_query                       = \
            SELECT \
                    id, name, description \
            FROM \
                    products_description;
sql_field_string = name
   sql_query_info = SELECT * FROM products_description WHERE id=$id

Is it possible to get the full text result like name and description instead of above array ?

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

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

发布评论

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

评论(2

霓裳挽歌倾城醉 2024-12-07 15:48:34

Sphinx 为您提供数据库记录的索引,但不存储它。
您必须从搜索结果中获取 id 并编写另一个 sql select 来从该行中获取数据。

Sphinx provides you the index of your database record but not store it.
You have to fetch the id from search result and write another sql select to fetch data from that row.

煞人兵器 2024-12-07 15:48:34

好的,我想你可以从 Sphinx 1-10beta 版本获取字符串数据。
您可以将所需的字段添加为源定义中的属性。

在此处检查您需要使用的内容:

SphinxSearch.com 中的sql_attr_string 说明< /a>

例如,

我有一个包含事件数据的索引:

sql_query = \
            SELECT\
                    p.place_id,\
                    p.place_id as place_id_attr,\
                    ...
                    ...
            FROM\
                    places p\
                    .......
                    ....
            GROUP BY\
                    p.place_id

    sql_attr_uint = place_id_attr
    sql_field_string = title
    sql_field_string = title_normalized
    sql_field_string = subtitle
    sql_field_string = description
    ....

这样,您就可以从 attrs 数组内的 php 代码中获取字段。

一个重要的细节:我使用 sql_field_string 因为我对文本进行了一些操作,我的意思是过滤器、订单等。如果您只需要信息,您可以使用 sql_attr_string,正如我发布的链接中所解释的那样。

我希望这有帮助! :)

最好的,

Ok, I think you can get the string data from the 1-10beta version of Sphinx.
You can add the fields you need as attributes in your source definition.

Check here what you need to use:

sql_attr_string explanation in SphinxSearch.com

For example,

I have an index with events data:

sql_query = \
            SELECT\
                    p.place_id,\
                    p.place_id as place_id_attr,\
                    ...
                    ...
            FROM\
                    places p\
                    .......
                    ....
            GROUP BY\
                    p.place_id

    sql_attr_uint = place_id_attr
    sql_field_string = title
    sql_field_string = title_normalized
    sql_field_string = subtitle
    sql_field_string = description
    ....

In that way you have your fields available from the php code inside the attrs array.

One important detail: I'm using sql_field_string because I make some operations with the texts, I mean, filters, orders and so. If you need only the information you could use sql_attr_string as they explain in the link I posted.

I hope this helps! :)

bests,

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