1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Trait SearchResultGetTrait|Firesphere\SolrSearch\Traits\SearchResultGetTrait Getters for |
4
|
|
|
* {@link \Firesphere\SolrSearch\Results\SearchResult} |
5
|
|
|
* |
6
|
|
|
* @package Firesphere\Solr\Search |
7
|
|
|
* @author Simon `Firesphere` Erkelens; Marco `Sheepy` Hermo |
8
|
|
|
* @copyright Copyright (c) 2018 - now() Firesphere & Sheepy |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace Firesphere\SolrSearch\Traits; |
12
|
|
|
|
13
|
|
|
use SilverStripe\ORM\ArrayList; |
14
|
|
|
use SilverStripe\View\ArrayData; |
15
|
|
|
use Solarium\Component\Result\Highlighting\Highlighting; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Trait SearchResultGetTrait |
19
|
|
|
* |
20
|
|
|
* Getters for search results to keep the {@link SearchResult} class clean. |
21
|
|
|
* |
22
|
|
|
* @package Firesphere\Solr\Search |
23
|
|
|
*/ |
24
|
|
|
trait SearchResultGetTrait |
25
|
|
|
{ |
26
|
|
|
/** |
27
|
|
|
* @var int Total items in the result |
28
|
|
|
*/ |
29
|
|
|
protected $totalItems; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @var ArrayData Facet results |
33
|
|
|
*/ |
34
|
|
|
protected $facets; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @var Highlighting Highlighting |
38
|
|
|
*/ |
39
|
|
|
protected $highlight; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @var ArrayList Spellcheck results |
43
|
|
|
*/ |
44
|
|
|
protected $spellcheck; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @var string Collated spellcheck |
48
|
|
|
*/ |
49
|
|
|
protected $collatedSpellcheck; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Retrieve the facets from the results |
53
|
|
|
* |
54
|
|
|
* @return ArrayData |
55
|
|
|
*/ |
56
|
2 |
|
public function getFacets(): ArrayData |
57
|
|
|
{ |
58
|
2 |
|
return $this->facets; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Get the collated spellcheck |
63
|
|
|
* |
64
|
|
|
* @return string |
65
|
|
|
*/ |
66
|
6 |
|
public function getCollatedSpellcheck() |
67
|
|
|
{ |
68
|
6 |
|
return $this->collatedSpellcheck; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* Get the highlighting |
73
|
|
|
* |
74
|
|
|
* @return Highlighting|null |
75
|
|
|
*/ |
76
|
2 |
|
public function getHighlight() |
77
|
|
|
{ |
78
|
2 |
|
return $this->highlight; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* Get the spellchecked results |
83
|
|
|
* |
84
|
|
|
* @return ArrayList |
85
|
|
|
*/ |
86
|
1 |
|
public function getSpellcheck(): ArrayList |
87
|
|
|
{ |
88
|
1 |
|
return $this->spellcheck; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* Total items in the result |
93
|
|
|
* |
94
|
|
|
* @return int |
95
|
|
|
*/ |
96
|
3 |
|
public function getTotalItems(): int |
97
|
|
|
{ |
98
|
3 |
|
return $this->totalItems; |
99
|
|
|
} |
100
|
|
|
} |
101
|
|
|
|