1 | <?php |
||
2 | |||
3 | namespace Mdiyakov\DoctrineSolrBundle\Query\Suggest\Solarium; |
||
4 | |||
5 | use Solarium\Core\Query\Query as BaseQuery; |
||
6 | |||
7 | class Query extends BaseQuery |
||
0 ignored issues
–
show
Deprecated Code
introduced
by
![]() |
|||
8 | { |
||
9 | /** |
||
10 | * Default options |
||
11 | * |
||
12 | * @var array |
||
13 | */ |
||
14 | protected $options = array( |
||
15 | 'handler' => 'suggest', |
||
16 | 'resultclass' => 'Mdiyakov\DoctrineSolrBundle\Query\Suggest\Solarium\Result\Result', |
||
17 | 'termclass' => 'Mdiyakov\DoctrineSolrBundle\Query\Suggest\Solarium\Result\Term', |
||
18 | 'omitheader' => true, |
||
19 | ); |
||
20 | |||
21 | |||
22 | /** |
||
23 | * Get type for this query |
||
24 | * |
||
25 | * @return string |
||
26 | */ |
||
27 | public function getType() |
||
28 | { |
||
29 | return 'suggester'; |
||
30 | } |
||
31 | |||
32 | /** |
||
33 | * Get a requestbuilder for this query |
||
34 | * |
||
35 | * @return RequestBuilder |
||
36 | */ |
||
37 | public function getRequestBuilder() |
||
38 | { |
||
39 | return new RequestBuilder; |
||
40 | } |
||
41 | |||
42 | /** |
||
43 | * Get a response parser for this query |
||
44 | * |
||
45 | * @return ResponseParser |
||
46 | */ |
||
47 | public function getResponseParser() |
||
48 | { |
||
49 | return new ResponseParser; |
||
50 | } |
||
51 | |||
52 | /** |
||
53 | * Set query option |
||
54 | * |
||
55 | * Query to spellcheck |
||
56 | * |
||
57 | * @param string $query |
||
58 | * @return self Provides fluent interface |
||
59 | */ |
||
60 | public function setQuery($query) |
||
61 | { |
||
62 | return $this->setOption('query', $query); |
||
63 | } |
||
64 | |||
65 | /** |
||
66 | * Get query option |
||
67 | * |
||
68 | * @return string|null |
||
69 | */ |
||
70 | public function getQuery() |
||
71 | { |
||
72 | return $this->getOption('query'); |
||
73 | } |
||
74 | |||
75 | /** |
||
76 | * Set dictionary option |
||
77 | * |
||
78 | * The name of the dictionary to use |
||
79 | * |
||
80 | * @param string $dictionary |
||
81 | * @return self Provides fluent interface |
||
82 | */ |
||
83 | public function addDictionary($dictionary) |
||
84 | { |
||
85 | $dictionaries = $this->getOption('dictionaries'); |
||
86 | if (!$dictionaries) { |
||
87 | $dictionaries = []; |
||
88 | } |
||
89 | $dictionaries[] = $dictionary; |
||
90 | |||
91 | return $this->setOption('dictionaries', $dictionaries); |
||
92 | } |
||
93 | |||
94 | /** |
||
95 | * Get dictionary option |
||
96 | * |
||
97 | * @return string[]|null |
||
98 | */ |
||
99 | public function getDictionaries() |
||
100 | { |
||
101 | return $this->getOption('dictionaries'); |
||
102 | } |
||
103 | |||
104 | /** |
||
105 | * Set count option |
||
106 | * |
||
107 | * The maximum number of suggestions to return |
||
108 | * |
||
109 | * @param int $count |
||
110 | * @return self Provides fluent interface |
||
111 | */ |
||
112 | public function setCount($count) |
||
113 | { |
||
114 | return $this->setOption('count', $count); |
||
115 | } |
||
116 | |||
117 | /** |
||
118 | * Get count option |
||
119 | * |
||
120 | * @return int|null |
||
121 | */ |
||
122 | public function getCount() |
||
123 | { |
||
124 | return $this->getOption('count'); |
||
125 | } |
||
126 | |||
127 | /** |
||
128 | * @param string $contextFilterQuery |
||
129 | * @return \Solarium\Core\Configurable |
||
130 | */ |
||
131 | public function setContextFieldQuery($contextFilterQuery) |
||
132 | { |
||
133 | return $this->setOption('context_filter_query', $contextFilterQuery); |
||
134 | } |
||
135 | |||
136 | /** |
||
137 | * Get count option |
||
138 | * |
||
139 | * @return string|null |
||
140 | */ |
||
141 | public function getContextFieldQuery() |
||
142 | { |
||
143 | return $this->getOption('context_filter_query'); |
||
144 | } |
||
145 | } |