1 | <?php |
||
13 | class Algolia implements SearchIndexHandler |
||
14 | { |
||
15 | /** @var \AlgoliaSearch\Client */ |
||
16 | protected $algolia; |
||
17 | |||
18 | /** @var \AlgoliaSearch\Index */ |
||
19 | public $index; |
||
20 | |||
21 | public function __construct(Client $algolia) |
||
25 | |||
26 | /** |
||
27 | * Set the name of the index that should be used by default. |
||
28 | * |
||
29 | * @param $indexName |
||
30 | * |
||
31 | * @return $this |
||
32 | */ |
||
33 | public function setIndexName($indexName) |
||
39 | |||
40 | /** |
||
41 | * Add or update the given searchable subject or array of subjects or Traversable object containing subjects. |
||
42 | * |
||
43 | * @param Searchable|array|Traversable $subject |
||
44 | */ |
||
45 | public function upsertToIndex($subject) |
||
73 | |||
74 | /** |
||
75 | * Remove the given subject from the search index. |
||
76 | * |
||
77 | * @param Searchable $subject |
||
78 | */ |
||
79 | public function removeFromIndex(Searchable $subject) |
||
83 | |||
84 | /** |
||
85 | * Remove an item from the search index by type and id. |
||
86 | * |
||
87 | * @param string $type |
||
88 | * @param int $id |
||
89 | */ |
||
90 | public function removeFromIndexByTypeAndId($type, $id) |
||
94 | |||
95 | /** |
||
96 | * Remove everything from the index. |
||
97 | * |
||
98 | * @return mixed |
||
99 | */ |
||
100 | public function clearIndex() |
||
104 | |||
105 | /** |
||
106 | * Get the results for the given query. |
||
107 | * |
||
108 | * @param string|array|\Spatie\SearchIndex\Query\Algolia\SearchQuery $query |
||
109 | * |
||
110 | * @return mixed |
||
111 | */ |
||
112 | public function getResults($query) |
||
130 | |||
131 | /** |
||
132 | * Get the id parameter that is used by Algolia as an array. |
||
133 | * |
||
134 | * @param Searchable $subject |
||
135 | * |
||
136 | * @return string |
||
137 | */ |
||
138 | protected function getAlgoliaId($subject) |
||
142 | |||
143 | /** |
||
144 | * Get the underlying client. |
||
145 | * |
||
146 | * @return \AlgoliaSearch\Client |
||
147 | */ |
||
148 | public function getClient() |
||
152 | } |
||
153 |