Files
Phraseanet/lib/Alchemy/Phrasea/SearchEngine/Elastic/ElasticsearchOptions.php
Benoît Burnichon 51023c5533 bump copyright year
2016-01-05 13:38:14 +01:00

187 lines
3.5 KiB
PHP

<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2016 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\Phrasea\SearchEngine\Elastic;
class ElasticsearchOptions
{
/** @var string */
private $host;
/** @var int */
private $port;
/** @var string */
private $indexName;
/** @var int */
private $shards;
/** @var int */
private $replicas;
/** @var int */
private $minScore;
/** @var bool */
private $highlight;
/**
* Factory method to hydrate an instance from serialized options
*
* @param array $options
* @return self
*/
public static function fromArray(array $options)
{
$options = array_replace([
'host' => '127.0.0.1',
'port' => 9200,
'index' => '',
'shards' => 3,
'replicas' => 0,
'minScore' => 4,
'highlight' => true
], $options);
$self = new self();
$self->setHost($options['host']);
$self->setPort($options['port']);
$self->setIndexName($options['index']);
$self->setShards($options['shards']);
$self->setReplicas($options['replicas']);
$self->setMinScore($options['minScore']);
$self->setHighlight($options['highlight']);
return $self;
}
/**
* @return array
*/
public function toArray()
{
return [
'host' => $this->host,
'port' => $this->port,
'index' => $this->indexName,
'shards' => $this->shards,
'replicas' => $this->replicas,
'minScore' => $this->minScore,
'highlight' => $this->highlight,
];
}
/**
* @param string $host
*/
public function setHost($host)
{
$this->host = $host;
}
/**
* @return string
*/
public function getHost()
{
return $this->host;
}
/**
* @param int $port
*/
public function setPort($port)
{
$this->port = (int)$port;
}
/**
* @return int
*/
public function getPort()
{
return $this->port;
}
/**
* @param int $minScore
*/
public function setMinScore($minScore)
{
$this->minScore = (int)$minScore;
}
/**
* @return int
*/
public function getMinScore()
{
return $this->minScore;
}
/**
* @param string $indexName
*/
public function setIndexName($indexName)
{
$this->indexName = $indexName;
}
/**
* @return string
*/
public function getIndexName()
{
return $this->indexName;
}
/**
* @param int $shards
*/
public function setShards($shards)
{
$this->shards = (int)$shards;
}
/**
* @return int
*/
public function getShards()
{
return $this->shards;
}
/**
* @param int $replicas
*/
public function setReplicas($replicas)
{
$this->replicas = (int)$replicas;
}
/**
* @return int
*/
public function getReplicas()
{
return $this->replicas;
}
/**
* @return bool
*/
public function getHighlight()
{
return $this->highlight;
}
/**
* @param bool $highlight
*/
public function setHighlight($highlight)
{
$this->highlight = $highlight;
}
}