Sphinx - 无法在查询中使用字段属性

发布于 2024-12-10 04:24:48 字数 1728 浏览 0 评论 0原文

我无法在 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 技术交流群。

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

发布评论

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

评论(2

浮萍、无处依 2024-12-17 04:24:48

在sql中你有“rows_src1”表,在sphinx.conf中你有“files”表

In sql you have "rows_src1" table , in sphinx.conf you have "files" as table

温柔女人霸气范 2024-12-17 04:24:48

字段名称需要在 sphinx.conf 中定义。添加“rt_field”条目为我解决了这个问题。

Field names need to be defined in sphinx.conf. Adding an entry for "rt_field" solved this for me.

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