@@ -230,6 +230,10 @@ discard block |
||
230 | 230 | /* |
231 | 231 | Set the highlight fields for subsequent searches |
232 | 232 | */ |
233 | + |
|
234 | + /** |
|
235 | + * @param string[] $newHighlightedFields |
|
236 | + */ |
|
233 | 237 | public function setHighlightedFields($newHighlightedFields) { |
234 | 238 | $this->highlightedFields = $newHighlightedFields; |
235 | 239 | } |
@@ -242,7 +246,7 @@ discard block |
||
242 | 246 | * @param string $q query string, e.g. 'New Zealand' |
243 | 247 | * @param array $fieldsToSearch Mapping of name to an array of mapping Weight and Elastic mapping, |
244 | 248 | * e.g. array('Title' => array('Weight' => 2, 'Type' => 'string')) |
245 | - * @return ArrayList SilverStripe DataObjects returned from the search against ElasticSearch |
|
249 | + * @return \PaginatedList SilverStripe DataObjects returned from the search against ElasticSearch |
|
246 | 250 | */ |
247 | 251 | public function search($q, $fieldsToSearch = null, $testMode = false) { |
248 | 252 | if ($this->locale == null) { |
@@ -307,6 +311,10 @@ discard block |
||
307 | 311 | |
308 | 312 | |
309 | 313 | /* Perform an autocomplete search */ |
314 | + |
|
315 | + /** |
|
316 | + * @param string $q |
|
317 | + */ |
|
310 | 318 | public function autocomplete_search($q, $field) { |
311 | 319 | if ($this->locale == null) { |
312 | 320 | if (class_exists('Translatable') && \SiteTree::has_extension('Translatable')) { |
@@ -358,11 +366,11 @@ discard block |
||
358 | 366 | |
359 | 367 | /** |
360 | 368 | * Perform a 'More Like This' search, aka relevance feedback, using the provided indexed DataObject |
361 | - * @param DataObject $indexedItem A DataObject that has been indexed in Elasticsearch |
|
369 | + * @param \DataObject|null $indexedItem A DataObject that has been indexed in Elasticsearch |
|
362 | 370 | * @param array $fieldsToSearch array of fieldnames to search, mapped to weighting |
363 | 371 | * @param $$testMode Use all shards, not just one, for consistent results during unit testing. See |
364 | 372 | * https://www.elastic.co/guide/en/elasticsearch/guide/current/relevance-is-broken.html#relevance-is-broken |
365 | - * @return resultList List of results |
|
373 | + * @return \PaginatedList List of results |
|
366 | 374 | */ |
367 | 375 | public function moreLikeThis($indexedItem, $fieldsToSearch, $testMode = false) { |
368 | 376 | echo "INDEXED ITEM:".$indexedItem; |
@@ -469,6 +477,9 @@ discard block |
||
469 | 477 | return $result; |
470 | 478 | } |
471 | 479 | |
480 | + /** |
|
481 | + * @return string |
|
482 | + */ |
|
472 | 483 | public function getSuggestedQuery() { |
473 | 484 | return $this->SuggestedQuery; |
474 | 485 | } |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | /** |
5 | 5 | * Alter the query or add to it, perhaps for example adding aggregation |
6 | 6 | * @param Elastic\Query &$query query object from Elastica |
7 | - * @return [type] [description] |
|
7 | + * @return void [description] |
|
8 | 8 | */ |
9 | 9 | public function augmentQuery(&$query); |
10 | 10 | |
@@ -12,6 +12,7 @@ discard block |
||
12 | 12 | * Update filters, perhaps remaps them, prior to performing a search. |
13 | 13 | * This allows for aggregation values to be updated prior to rendering. |
14 | 14 | * @param array &$filters array of key/value pairs for query filtering |
15 | + * @return void |
|
15 | 16 | */ |
16 | 17 | public function updateFilters(&$filters); |
17 | 18 | |
@@ -19,7 +20,7 @@ discard block |
||
19 | 20 | * Manipulate the array of aggregations post search butprior to rendering |
20 | 21 | * them in a template. |
21 | 22 | * @param [type] &$aggs [description] |
22 | - * @return [type] [description] |
|
23 | + * @return void [description] |
|
23 | 24 | */ |
24 | 25 | public function updateAggregation(&$aggs); |
25 | 26 |
@@ -62,6 +62,9 @@ discard block |
||
62 | 62 | } |
63 | 63 | |
64 | 64 | |
65 | + /** |
|
66 | + * @param boolean $newShowResultsForEmptyQuery |
|
67 | + */ |
|
65 | 68 | public function setShowResultsForEmptyQuery($newShowResultsForEmptyQuery) { |
66 | 69 | $this->showResultsForEmptyQuery = $newShowResultsForEmptyQuery; |
67 | 70 | } |
@@ -72,11 +75,17 @@ discard block |
||
72 | 75 | } |
73 | 76 | |
74 | 77 | |
78 | + /** |
|
79 | + * @param integer $newPageLength |
|
80 | + */ |
|
75 | 81 | public function setPageLength($newPageLength) { |
76 | 82 | $this->pageLength = $newPageLength; |
77 | 83 | } |
78 | 84 | |
79 | 85 | |
86 | + /** |
|
87 | + * @param integer $newStart |
|
88 | + */ |
|
80 | 89 | public function setStart($newStart) { |
81 | 90 | $this->start = $newStart; |
82 | 91 | } |
@@ -317,6 +326,9 @@ discard block |
||
317 | 326 | } |
318 | 327 | |
319 | 328 | |
329 | + /** |
|
330 | + * @param Query $query |
|
331 | + */ |
|
320 | 332 | private function addAggregation(&$query) { |
321 | 333 | // aggregation (optional) |
322 | 334 | if ($this->manipulatorInstance) { |
@@ -6,6 +6,10 @@ discard block |
||
6 | 6 | private static $ranged_aggregations = array(); |
7 | 7 | |
8 | 8 | |
9 | + /** |
|
10 | + * @param string $title |
|
11 | + * @param string $field |
|
12 | + */ |
|
9 | 13 | public function __construct($title, $field) { |
10 | 14 | $this->Title = $title; |
11 | 15 | $this->Range = new \Elastica\Aggregation\Range($title); |
@@ -14,6 +18,11 @@ discard block |
||
14 | 18 | } |
15 | 19 | |
16 | 20 | |
21 | + /** |
|
22 | + * @param double $from |
|
23 | + * @param double $to |
|
24 | + * @param string $name |
|
25 | + */ |
|
17 | 26 | public function addRange($from, $to, $name) { |
18 | 27 | $this->Range->addRange($from,$to,$name); |
19 | 28 | } |
@@ -250,6 +250,9 @@ |
||
250 | 250 | } |
251 | 251 | |
252 | 252 | |
253 | + /** |
|
254 | + * @return integer |
|
255 | + */ |
|
253 | 256 | public function getTotalItems() { |
254 | 257 | $this->getResults(); |
255 | 258 | return $this->TotalItems; |
@@ -1036,6 +1036,7 @@ |
||
1036 | 1036 | /** |
1037 | 1037 | * Test searching |
1038 | 1038 | * http://stackoverflow.com/questions/28305250/elasticsearch-customize-score-for-synonyms-stemming |
1039 | + * @param string $queryText |
|
1039 | 1040 | */ |
1040 | 1041 | private function search($queryText,$fields = array('Title' => 1, 'Description' => 1), |
1041 | 1042 | $filters = array()) { |
@@ -153,6 +153,9 @@ |
||
153 | 153 | |
154 | 154 | /** |
155 | 155 | * Simulate a call to Elastica to get suggestions for a given phrase |
156 | + * @param string $phrase |
|
157 | + * @param string $suggestion |
|
158 | + * @param string $highlightedSuggestion |
|
156 | 159 | * @return [type] [description] |
157 | 160 | */ |
158 | 161 | private function getSuggestionArray($phrase, $suggestion, $highlightedSuggestion) { |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | * Note: characters are stripped from the content; make sure that your assertions take this into account. |
103 | 103 | * |
104 | 104 | * @param string $selector A basic CSS selector, e.g. 'li.jobs h3' |
105 | - * @param array|string $expectedMatches The content of at least one of the matched tags |
|
105 | + * @param integer $index |
|
106 | 106 | * @throws PHPUnit_Framework_AssertionFailedError |
107 | 107 | * @return boolean |
108 | 108 | */ |
@@ -133,6 +133,12 @@ discard block |
||
133 | 133 | /* |
134 | 134 | Check all the nodes matching the selector for attribute name = expected value |
135 | 135 | */ |
136 | + |
|
137 | + /** |
|
138 | + * @param string $selector |
|
139 | + * @param string $attributeName |
|
140 | + * @param string $expectedValue |
|
141 | + */ |
|
136 | 142 | public function assertAttributeHasExactValue($selector, $attributeName, $expectedValue) { |
137 | 143 | $items = $this->cssParser()->getBySelector($selector); |
138 | 144 | foreach ($items as $item) { |
@@ -141,6 +147,9 @@ discard block |
||
141 | 147 | } |
142 | 148 | |
143 | 149 | |
150 | + /** |
|
151 | + * @param string $selector |
|
152 | + */ |
|
144 | 153 | public function assertAttributesHaveExactValues($selector, $expectedValues) { |
145 | 154 | $attributeNames = array_keys($expectedValues); |
146 | 155 | $items = $this->cssParser()->getBySelector($selector); |
@@ -154,6 +163,10 @@ discard block |
||
154 | 163 | } |
155 | 164 | |
156 | 165 | |
166 | + /** |
|
167 | + * @param string $selector |
|
168 | + * @param integer $expectedAmount |
|
169 | + */ |
|
157 | 170 | public function assertNumberOfNodes($selector, $expectedAmount) { |
158 | 171 | $items = $this->cssParser()->getBySelector($selector); |
159 | 172 | foreach ($items as $item) { |
@@ -106,6 +106,10 @@ |
||
106 | 106 | } |
107 | 107 | |
108 | 108 | |
109 | + /** |
|
110 | + * @param string $fieldName |
|
111 | + * @param string $message |
|
112 | + */ |
|
109 | 113 | private function checkForError($fieldName, $badValue, $message) { |
110 | 114 | $this->ElasticSearchPage->$fieldName = $badValue; |
111 | 115 |