SphinxClient::query

(PECL sphinx >= 0.1.0)

SphinxClient::queryВыполнение поискового запроса

Описание

public array SphinxClient::query ( string $query [, string $index = "*" [, string $comment = "" ]] )

Подключается к серверу searchd, выполняет указанный поисковый запрос с текущими настройками, получает и возвращает набор результатов.

Список параметров

query

Строка запроса.

index

Название индекса (или множество названий).

comment

Возвращаемые значения

При успехе SphinxClient::query() возвращает список найденных совпадений и дополнительную статистику по запросу. Набор результатов - это (если не указано иное) ассоциативный массив со следующими ключами и значениями:

Структура набора результатов
Ключ Описание значения
"matches" Массив с ID найденных документов в качестве ключей и их весами и аттрибутами в качестве значений.
"total" Общее число найденных и полученных совпадений (зависит от ваших настроек).
"total_found" Общее число найденных документов, удовлетворяющих запросу.
"words" Массив со словами (приведенными к одному регистру и словоформе) в качестве ключей и статистика по этим словам в качестве значений.
"error" Ошибка запроса, полученная от searchd
"warning" Предупреждение, полученное от searchd

Смотрите также

Коментарии

It appears that Query() (or the Sphinx program in general) does have some kind of limit imposed on the maximum length of a query submission. Stumbled across this limitation when trying to perform some searches based on content from user-submitted e-mails.

In looking at the returned array, the 'words' portion only accounts for the first 8 or 9 words of the long query. I'm assuming that the rest of the string is being truncated. The number of accepted words appears to change based on the total length of the words. Just a heads-up.
2008-12-11 10:16:19
http://php5.kiev.ua/manual/ru/sphinxclient.query.html
Автор:
There is also a "status" key showing in what status query has ended. 
Here are codes, taken from searchd.cpp:

<?php
/// known status return codes
enum SearchdStatus_e
{
       
SEARCHD_OK              0,    ///< general success, command-specific reply follows
       
SEARCHD_ERROR   1,    ///< general failure, error message follows
       
SEARCHD_RETRY   2,    ///< temporary failure, error message follows, client should retry later
       
SEARCHD_WARNING 3             ///< general success, warning message and command-specific reply follow
};
?>
2010-09-15 10:54:36
http://php5.kiev.ua/manual/ru/sphinxclient.query.html
public array SphinxClient::query ( string $query [, string $index = "*" [, string $comment = "" ]] )

If you add a value for comment, you can retrieve them in sphinx query log.
2011-02-14 05:35:02
http://php5.kiev.ua/manual/ru/sphinxclient.query.html
You can limit the search to certain indexes separated by anything other than letters, numbers, underscores, and dashes.

<?php
// All valid
$client->Query('test''main delta');
$client->Query('test''main;delta');
$client->Query('test''main, delta');
$client->Query('test''main:delta');
?>
2015-09-12 08:26:45
http://php5.kiev.ua/manual/ru/sphinxclient.query.html

    Поддержать сайт на родительском проекте КГБ