blob: 00f21e4458e0cae501b24f3359a2a010c6f86f3a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
<?php
namespace Elastica\Suggest;
use Elastica\Param;
/**
* Class AbstractSuggestion.
*/
abstract class AbstractSuggest extends Param
{
/**
* @var string the name of this suggestion
*/
protected $_name;
/**
* @var string the text for this suggestion
*/
protected $_text;
/**
* @param string $name
* @param string $field
*/
public function __construct($name, $field)
{
$this->_name = $name;
$this->setField($field);
}
/**
* Suggest text must be set either globally or per suggestion.
*
* @param string $text
*
* @return $this
*/
public function setText($text)
{
$this->_text = $text;
return $this;
}
/**
* @param string $field
*
* @return $this
*/
public function setField($field)
{
return $this->setParam('field', $field);
}
/**
* @param int $size
*
* @return $this
*/
public function setSize($size)
{
return $this->setParam('size', $size);
}
/**
* @param int $size maximum number of suggestions to be retrieved from each shard
*
* @return $this
*/
public function setShardSize($size)
{
return $this->setParam('shard_size', $size);
}
/**
* Retrieve the name of this suggestion.
*
* @return string
*/
public function getName()
{
return $this->_name;
}
/**
* @return array
*/
public function toArray()
{
$array = parent::toArray();
if (isset($this->_text)) {
$array['text'] = $this->_text;
}
return $array;
}
}
|