1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Kunstmaan\SearchBundle\Provider; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Interface for a SearchProvider |
7
|
|
|
*/ |
8
|
|
|
interface SearchProviderInterface |
9
|
|
|
{ |
10
|
|
|
/** |
11
|
|
|
* Returns a unique name for the SearchProvider |
12
|
|
|
* |
13
|
|
|
* @return string |
14
|
|
|
*/ |
15
|
|
|
public function getName(); |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Return the client object |
19
|
|
|
* |
20
|
|
|
* @return mixed |
21
|
|
|
*/ |
22
|
|
|
public function getClient(); |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Create an index |
26
|
|
|
* |
27
|
|
|
* @param string $indexName Name of the index |
28
|
|
|
*/ |
29
|
|
|
public function createIndex($indexName); |
|
|
|
|
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Return the index object |
33
|
|
|
* |
34
|
|
|
* @param $indexName |
35
|
|
|
* |
36
|
|
|
* @return mixed |
37
|
|
|
*/ |
38
|
|
|
public function getIndex($indexName); |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Create a document |
42
|
|
|
* |
43
|
|
|
* @param string $uid |
44
|
|
|
* @param mixed $document |
45
|
|
|
* @param string $indexName |
46
|
|
|
* @param string $indexType |
47
|
|
|
* |
48
|
|
|
* @return mixed |
49
|
|
|
*/ |
50
|
|
|
public function createDocument($document, $uid, $indexName = '', $indexType = ''); |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Add a document to the index |
54
|
|
|
* |
55
|
|
|
* @param string $indexName Name of the index |
56
|
|
|
* @param string $indexType Type of the index to add the document to |
57
|
|
|
* @param array $document The document to index |
58
|
|
|
* @param string $uid Unique ID for this document, this will allow the document to be overwritten by new data |
59
|
|
|
* instead of being duplicated |
60
|
|
|
*/ |
61
|
|
|
public function addDocument($indexName, $indexType, $document, $uid); |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* Add a collection of documents at once |
65
|
|
|
* |
66
|
|
|
* @param mixed $documents |
67
|
|
|
* @param string $indexName Name of the index |
68
|
|
|
* @param string $indexType Type of the index the document is located |
69
|
|
|
* |
70
|
|
|
* @return mixed |
71
|
|
|
*/ |
72
|
|
|
public function addDocuments($documents, $indexName = '', $indexType = ''); |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* delete a document from the index |
76
|
|
|
* |
77
|
|
|
* @param string $indexName Name of the index |
78
|
|
|
* @param string $indexType Type of the index the document is located |
79
|
|
|
* @param string $uid Unique ID of the document to be delete |
80
|
|
|
*/ |
81
|
|
|
public function deleteDocument($indexName, $indexType, $uid); |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @param string $indexName |
85
|
|
|
* @param string $indexType |
86
|
|
|
* @param array $ids |
87
|
|
|
*/ |
88
|
|
|
public function deleteDocuments($indexName, $indexType, array $ids); |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* Delete an index |
92
|
|
|
* |
93
|
|
|
* @param string $indexName Name of the index to delete |
94
|
|
|
*/ |
95
|
|
|
public function deleteIndex($indexName); |
96
|
|
|
} |
97
|
|
|
|
For interface and abstract methods, it is impossible to infer the return type from the immediate code. In these cases, it is generally advisible to explicitly annotate these methods with a
@return
doc comment to communicate to implementors of these methods what they are expected to return.