PHP Doku:: Execute search query - sphinxclient.query.html

Verlauf / Chronik / History: (1) anzeigen

Sie sind hier:
Doku-StartseitePHP-HandbuchFunktionsreferenzSuchmaschinenerweiterungenSphinx ClientThe SphinxClient classSphinxClient::query

Ein Service von Reinhard Neidl - Webprogrammierung.

The SphinxClient class

<<SphinxClient::open

SphinxClient::resetFilters>>

SphinxClient::query

(PECL sphinx >= 0.1.0)

SphinxClient::queryExecute search query

Beschreibung

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

Connects to searchd server, runs the given search query with the current settings, obtains and returns the result set.

Parameter-Liste

query

Query string.

index

An index name (or names).

comment

Rückgabewerte

On success, SphinxClient::query() returns a list of found matches and additional per-query statistics. The result set is a hash utilize other structures instead of hash) with the following keys and values:
Result set structure
Key Value description
"matches" An array with found document IDs as keys and their weight and attributes values as values
"total" Total number of matches found and retrieved (depends on your settings)
"total_found" Total number of found documents matching the query
"words" An array with words (case-folded and stemmed) as keys and per-word statistics as values
"error" Query error message reported by searchd
"warning" Query warning reported by searchd


2 BenutzerBeiträge:
- Beiträge aktualisieren...
php at senz dot su
15.09.2010 16:54
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
};
?>
fkoehl at gmail dot com
11.12.2008 17:16
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.



PHP Powered Diese Seite bei php.net
The PHP manual text and comments are covered by the Creative Commons Attribution 3.0 License © the PHP Documentation Group - Impressum - mail("TO:Reinhard Neidl",...)