在SphinxSearch(PHP)中搜索多个字段

在SphinxSearch(PHP)中搜索多个字段,php,indexing,sphinx,Php,Indexing,Sphinx,我有以下代码: $this->api = new App_Other_SphinxSearch(); $this->api->SetServer($host, $port); $this->api->SetConnectTimeout(1); $this->api->SetArrayResult(true); $results = $this->api->Query("@(title,content) test", 'members');

我有以下代码:

$this->api = new App_Other_SphinxSearch();
$this->api->SetServer($host, $port);
$this->api->SetConnectTimeout(1);
$this->api->SetArrayResult(true);
$results = $this->api->Query("@(title,content) test", 'members');

echo "<pre>";print_r($results);die;
数组中没有
匹配项
键,但是它得到了一些命中。我真的不明白为什么会发生这种情况,特别是因为如果我从命令行尝试相同的查询,一切都会正常工作

有什么帮助吗


编辑:像这样的查询仍然有效:
@*test
。但这并不是我想要的,因为它会在所有字段中进行搜索。

[total\u found]=>0
会在那里指出不匹配的地方

单词数组只告诉您现在有多少文档,以及该单词在任何(和所有)字段中出现的次数。(不考虑您的具体询问)

Sphinx缓存这些word统计信息,这有助于它对查询进行快速的健全性检查。当查询运行时,它可能最终不匹配任何文档(因为只有这样它才会应用字段级过滤器),即使找到了单个单词


这可以解释你对结果的误解,但不能解释为什么你会得到结果

您正在进入扩展模式查询(sphinx文档的链接证明了这一点),但sphinx API默认为所有查询模式。还要注意,标题和内容都在单词数组中,因此它们被当作普通关键字,而不是语法

所以你需要包括一个


顺便说一句,
@*test
,之所以有效,是因为在所有查询模式下,
@*
都会被忽略

给你一个词,我的朋友:lifesaver:)
注意,标题和内容在单词数组中,因此被视为普通关键字,而不是语法。
--我只是在发布问题后才发现,但不知道如何修复它。现在一切都好了。谢谢
Array
(
    [error] => 
    [warning] => 
    [status] => 0
    [fields] => Array
        (
            [0] => title
            [1] => content
        )

    [attrs] => Array
        (
            [created] => 2
            [content] => 7
        )

    [total] => 0
    [total_found] => 0
    [time] => 0.000
    [words] => Array
        (
            [title] => Array
                (
                    [docs] => 10
                    [hits] => 34
                )

            [content] => Array
                (
                    [docs] => 34
                    [hits] => 139
                )

            [test] => Array
                (
                    [docs] => 26
                    [hits] => 34
                )

        )

)
$this->api->SetMatchMode(SPH_MATCH_EXTENDED);