如何在 SPHINX 中获取文本结果
我正在尝试使用 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
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.
好的,我想你可以从 Sphinx 1-10beta 版本获取字符串数据。
您可以将所需的字段添加为源定义中的属性。
在此处检查您需要使用的内容:
SphinxSearch.com 中的sql_attr_string 说明< /a>
例如,
我有一个包含事件数据的索引:
这样,您就可以从 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:
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,