Class searchengine_connection

Description

The SearchEngine connection class

This class inherits the functionality of the 'search' class since mostly that is what we will be connecting to SearchEngine for. The Indexing and Control descendants can just ignore this inherited basic searching functionality. This class knows how to connect to a SearchEngine server and send and receive messages to/from it. Child classes which need to talk to this server to do indexing or querying should inherit this class.

Located in /search-lucene-defs.php (line 86)

search
   |
   --searchengine_connection
Direct descendents
Class Description
 class searchengine_msg The SearchEngine msg class. This is a raw class which holds the basic message fields and data and knows how to build them into a full message for sending to the SearchEngine server.
Variable Summary
 mixed $connected
 mixed $enabled
 mixed $host
 mixed $message
 mixed $port
 mixed $responsebuf
 mixed $sockfp
 mixed $timeoutsecs
 mixed $timer
Method Summary
 searchengine_connection searchengine_connection ([string $host = ""], [string $port = ""], [integer $timeoutsecs = ""])
 boolean send ([integer $timeoutsecs = ""])
 void set_host_and_port (string $host, string $port)
 void set_timeout (integer $timeoutsecs)
Variables
mixed $connected = false (line 110)

True if we are connected to socket

mixed $enabled = true (line 98)

Whether SearchEngine is enabled..

mixed $host = "" (line 89)

HOST running the SearchEngine query server

mixed $message = "" (line 101)

The message waiting to be sent

mixed $port = "" (line 91)

PORT that the server is listening on

mixed $responsebuf = "" (line 104)

Raw response content we receive back from the SearchEngine server

mixed $sockfp = false (line 107)

Socket file pointer

mixed $timeoutsecs = 10 (line 93)

Timeout for send in seconds

mixed $timer (line 113)

An execution timer

Inherited Variables

Inherited from search

search::$date_end
search::$date_fieldname
search::$date_start
search::$executed
search::$hit
search::$max_results
search::$query
search::$searchterm
search::$skip_results
search::$title
Methods
Constructor searchengine_connection (line 123)

Constructor - SearchEngine connection. Normally this will just be called with no host/port, and the object is just initialised ready for the call to send(). If called with host/port, then the connection is fired up immediately.

searchengine_connection searchengine_connection ([string $host = ""], [string $port = ""], [integer $timeoutsecs = ""])
  • string $host: Hostname or IP of SearchEngine server
  • string $port: Port of SearchEngine server
  • integer $timeoutsecs: Seconds to timeout the connection
send (line 224)

Sends a message to the SearchEngine server, and receives the response. We operate on the understanding that every time we send something to SearchEngine we expect a response. Since this method already calls the recieve() method, there is no need to call it from your application.

The content to be sent is expected to be already in the class string variable $message. The response is put into $response which is an array of LF-delimited lines sent back.

  • return: True if the message was sent ok
boolean send ([integer $timeoutsecs = ""])
  • integer $timeoutsecs: Override for timeout in seconds

Redefined in descendants as:
  • searchengine_msg::send() : Sends the current message to SearchEngine, and checks for protocol errors in the received response.
  • searchengine_querymsg::send() : Send the message to SearchEngine, and then post-process the response for
  • searchengine_indexmsg::send() : Send the message to SearchEngine, and then post-process the response for indication of a successful index operation. We expect to receive a response back from SearchEngine which has our serialno in it. This method returns True if the indexing was successful, else False.
  • searchengine_unindexmsg::send() : Send the message to SearchEngine, and then post-process the response for indication of a successful index operation.
  • searchengine_utilitymsg::send() : Send the message to SearchEngine, and then post-process the response for indication of a successful utility operation. We expect to receive a response back from SearchEngine which has nothing much it, unless there has been an error.
set_host_and_port (line 135)

Sets the search engine host and port for the connection

void set_host_and_port (string $host, string $port)
  • string $host: Hostname or IP of SearchEngine server
  • string $port: Port of SearchEngine server
set_timeout (line 203)

Set the socket timeout. Deals with the special case of setting the socket to non-blocking mode (zero timeout)..

void set_timeout (integer $timeoutsecs)
  • integer $timeoutsecs: Set the timeout in seconds

Inherited Methods

Inherited From search

 search::search()
 search::clear_daterange()
 search::clear_search()
 search::does_not_match()
 search::has_daterange()
 search::hitcount()
 search::initialise()
 search::match()
 search::may_match()
 search::must_match()
 search::reset_search()
 search::set_daterange()
 search::set_maxresults()
 search::set_skipresults()
 search::termcount()

Documentation generated by phpDocumentor 1.3.0RC3