99 lines
1.4 KiB
PHP
99 lines
1.4 KiB
PHP
<?php
|
|
class Metier_Search_Engine
|
|
{
|
|
protected $client = null;
|
|
protected $host = null;
|
|
protected $port = null;
|
|
protected $timeout = 1;
|
|
protected $offset = 0;
|
|
protected $limit = 300;
|
|
protected $max_matches = 1000;
|
|
protected $query = null;
|
|
|
|
public function __construct($version = 1)
|
|
{
|
|
//Load the API following the version
|
|
if ($version == 1){
|
|
require_once 'Vendors/sphinxapi/sphinxapi-0.9.9.php';
|
|
} elseif ($version == 2){
|
|
require_once 'Vendors/sphinxapi/sphinxapi-2.1.5.php';
|
|
}
|
|
}
|
|
|
|
/**
|
|
*
|
|
* @return boolean
|
|
*/
|
|
protected function loadClient()
|
|
{
|
|
if ( null === $this->host ) {
|
|
return false;
|
|
}
|
|
|
|
if ( null === $this->port ) {
|
|
return false;
|
|
}
|
|
|
|
$this->client = new SphinxClient();
|
|
$this->client->SetServer( $this->host, $this->port );
|
|
$this->client->SetConnectTimeout( $timeout );
|
|
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
*
|
|
* @param unknown $value
|
|
*/
|
|
protected function setHost($value)
|
|
{
|
|
$this->host = $value;
|
|
}
|
|
|
|
/**
|
|
*
|
|
* @param unknown $value
|
|
*/
|
|
protected function setPort($value)
|
|
{
|
|
$this->port = $value;
|
|
}
|
|
|
|
/**
|
|
*
|
|
* @param unknown $value
|
|
*/
|
|
protected function setOffset($value)
|
|
{
|
|
$this->offset = $value;
|
|
}
|
|
|
|
/**
|
|
*
|
|
* @param unknown $value
|
|
*/
|
|
protected function setLimit($value)
|
|
{
|
|
$this->limit = $value;
|
|
}
|
|
|
|
/**
|
|
*
|
|
* @param unknown $value
|
|
*/
|
|
protected function setMaxMatches($value)
|
|
{
|
|
$this->max_matches = $value;
|
|
}
|
|
|
|
/**
|
|
*
|
|
*/
|
|
protected function constructQuery($p)
|
|
{
|
|
$this->query = $p;
|
|
}
|
|
|
|
|
|
}
|