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
}
Field names need to be defined in sphinx.conf. Adding an entry for “rt_field” solved this for me.