Sphinx - 无法在查询中使用字段属性
我无法在 sphinx 查询中使用 @field-name ,但可以使用 @*
我可以在查询 test.documents 示例时使用 @field-name 属性,但不能用于我已索引的另一个表。
这是我的 PHP:
require_once('sphinxapi.php');
$this->sphinx = new SphinxClient;
$this->sphinx->setServer("localhost", 9312);
$this->sphinx->setMatchMode(SPH_MATCH_EXTENDED2);
//This works:
$result = $this->sphinx->query("@* bob");
var_dump($result);
//This doesn't work:
$result = $this->sphinx->query("@artist bob");
var_dump($result);
输出: /usr/local/sphinx/bin/indexer --all --rotate --dump-rows sphinxrows.txt
# === source src1 ts 1318588067
# Fri Oct 14 10:27:47 2011
#
# field 0: name
# field 1: filename
# field 2: artist
# sql_attr_uint = id_attr # attr 0
# sql_attr_timestamp = date_added # attr 1
#
DROP TABLE IF EXISTS rows_src1;
CREATE TABLE rows_src1 (
id VARCHAR(32) NOT NULL,
id_attr VARCHAR(4096) NOT NULL,
date_added VARCHAR(4096) NOT NULL,
name VARCHAR(4096) NOT NULL,
filename VARCHAR(4096) NOT NULL,
artist VARCHAR(4096) NOT NULL,
KEY(id) );
INSERT INTO rows_src1 VALUES ('6', '6', '0', 'track 1 title', 'track-1.wav', 'bob');
INSERT INTO rows_src1 VALUES ('70', '70', '0', 'track 2 title', 'track-2.wav', 'eric');
Sphinx.conf:
source src1
{
type = mysql
sql_query = \
SELECT id, id AS id_attr, UNIX_TIMESTAMP(date_added) AS date_added, name, filename, artist \
FROM files
sql_attr_uint = id_attr
sql_attr_timestamp = date_added
sql_query_info = SELECT * FROM files WHERE id=$id
}
I cannot use @field-name in my sphinx query, but I can use @*
I could use the @field-name attribute when querying the test.documents example, but not for another table I have indexed.
This is my PHP:
require_once('sphinxapi.php');
$this->sphinx = new SphinxClient;
$this->sphinx->setServer("localhost", 9312);
$this->sphinx->setMatchMode(SPH_MATCH_EXTENDED2);
//This works:
$result = $this->sphinx->query("@* bob");
var_dump($result);
//This doesn't work:
$result = $this->sphinx->query("@artist bob");
var_dump($result);
Output of: /usr/local/sphinx/bin/indexer --all --rotate --dump-rows sphinxrows.txt
# === source src1 ts 1318588067
# Fri Oct 14 10:27:47 2011
#
# field 0: name
# field 1: filename
# field 2: artist
# sql_attr_uint = id_attr # attr 0
# sql_attr_timestamp = date_added # attr 1
#
DROP TABLE IF EXISTS rows_src1;
CREATE TABLE rows_src1 (
id VARCHAR(32) NOT NULL,
id_attr VARCHAR(4096) NOT NULL,
date_added VARCHAR(4096) NOT NULL,
name VARCHAR(4096) NOT NULL,
filename VARCHAR(4096) NOT NULL,
artist VARCHAR(4096) NOT NULL,
KEY(id) );
INSERT INTO rows_src1 VALUES ('6', '6', '0', 'track 1 title', 'track-1.wav', 'bob');
INSERT INTO rows_src1 VALUES ('70', '70', '0', 'track 2 title', 'track-2.wav', 'eric');
Sphinx.conf:
source src1
{
type = mysql
sql_query = \
SELECT id, id AS id_attr, UNIX_TIMESTAMP(date_added) AS date_added, name, filename, artist \
FROM files
sql_attr_uint = id_attr
sql_attr_timestamp = date_added
sql_query_info = SELECT * FROM files WHERE id=$id
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在sql中你有“rows_src1”表,在sphinx.conf中你有“files”表
In sql you have "rows_src1" table , in sphinx.conf you have "files" as table
字段名称需要在 sphinx.conf 中定义。添加“rt_field”条目为我解决了这个问题。
Field names need to be defined in sphinx.conf. Adding an entry for "rt_field" solved this for me.