IIndex.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCP\FullTextSearch\Model;
  8. /**
  9. * Interface IIndex
  10. *
  11. * Index are generated by FullTextSearch to manage the status of a document
  12. * regarding the date of the last index and the date of the last modification
  13. * of the original document.
  14. *
  15. * The uniqueness of an IIndexDocument is made by the Id of the Content Provider
  16. * and the Id of the original document within the Content Provider.
  17. *
  18. * We will call original document the source from which the IIndexDocument is
  19. * generated. As an example, an original document can be a file, a mail, ...
  20. *
  21. * @since 15.0.0
  22. *
  23. */
  24. interface IIndex {
  25. /**
  26. * @since 15.0.0
  27. */
  28. public const INDEX_OK = 1;
  29. /**
  30. * @since 15.0.0
  31. */
  32. public const INDEX_IGNORE = 2;
  33. /**
  34. * @since 15.0.0
  35. */
  36. public const INDEX_META = 4;
  37. /**
  38. * @since 15.0.0
  39. */
  40. public const INDEX_CONTENT = 8;
  41. /**
  42. * @since 16.0.0
  43. */
  44. public const INDEX_PARTS = 16;
  45. /**
  46. * @since 15.0.0
  47. */
  48. public const INDEX_FULL = 28;
  49. /**
  50. * @since 15.0.0
  51. */
  52. public const INDEX_REMOVE = 32;
  53. /**
  54. * @since 15.0.0
  55. */
  56. public const INDEX_DONE = 64;
  57. /**
  58. * @since 15.0.0
  59. */
  60. public const INDEX_FAILED = 128;
  61. /**
  62. * @since 15.0.0
  63. */
  64. public const ERROR_FAILED = 1;
  65. /**
  66. * @since 15.0.0
  67. */
  68. public const ERROR_FAILED2 = 2;
  69. /**
  70. * @since 15.0.0
  71. */
  72. public const ERROR_FAILED3 = 4;
  73. /**
  74. * @since 15.0.0
  75. */
  76. public const ERROR_SEV_1 = 1;
  77. /**
  78. * @since 15.0.0
  79. */
  80. public const ERROR_SEV_2 = 2;
  81. /**
  82. * @since 15.0.0
  83. */
  84. public const ERROR_SEV_3 = 3;
  85. /**
  86. * @since 15.0.0
  87. */
  88. public const ERROR_SEV_4 = 4;
  89. /**
  90. * Get the Id of the Content Provider.
  91. *
  92. * @since 15.0.0
  93. *
  94. * @return string
  95. */
  96. public function getProviderId(): string;
  97. /**
  98. * Get the Id of the original document.
  99. *
  100. * @since 15.0.0
  101. *
  102. * @return string
  103. */
  104. public function getDocumentId(): string;
  105. /**
  106. * Get the collection of the index.
  107. * If empty (''), means collection is the default one used by the internal framework
  108. *
  109. * @since 24.0.0
  110. *
  111. * @return string
  112. */
  113. public function getCollection(): string;
  114. /**
  115. * Set the source of the original document.
  116. *
  117. * @since 15.0.0
  118. *
  119. * @param string $source
  120. *
  121. * @return IIndex
  122. */
  123. public function setSource(string $source): IIndex;
  124. /**
  125. * Get the source of the original document.
  126. *
  127. * @since 15.0.0
  128. *
  129. * @return string
  130. */
  131. public function getSource(): string;
  132. /**
  133. * Set the owner of the original document.
  134. *
  135. * @since 15.0.0
  136. *
  137. * @param string $ownerId
  138. *
  139. * @return IIndex
  140. */
  141. public function setOwnerId(string $ownerId): IIndex;
  142. /**
  143. * Get the owner of the original document.
  144. *
  145. * @since 15.0.0
  146. *
  147. * @return string
  148. */
  149. public function getOwnerId(): string;
  150. /**
  151. * Set the current index status (bit flag) of the original document.
  152. * If $reset is true, the status is reset to the defined value.
  153. *
  154. * @since 15.0.0
  155. *
  156. * @param int $status
  157. * @param bool $reset
  158. *
  159. * @return IIndex
  160. */
  161. public function setStatus(int $status, bool $reset = false): IIndex;
  162. /**
  163. * Get the current index status of the original document.
  164. *
  165. * @since 15.0.0
  166. *
  167. * @return int
  168. */
  169. public function getStatus(): int;
  170. /**
  171. * Check if the document fit a specific status.
  172. *
  173. * @since 15.0.0
  174. *
  175. * @param int $status
  176. *
  177. * @return bool
  178. */
  179. public function isStatus(int $status): bool;
  180. /**
  181. * Remove a status.
  182. *
  183. * @since 15.0.0
  184. *
  185. * @param int $status
  186. *
  187. * @return IIndex
  188. */
  189. public function unsetStatus(int $status): IIndex;
  190. /**
  191. * Add an option related to the original document (as string).
  192. *
  193. * @since 15.0.0
  194. *
  195. * @param string $option
  196. * @param string $value
  197. *
  198. * @return IIndex
  199. */
  200. public function addOption(string $option, string $value): IIndex;
  201. /**
  202. * Add an option related to the original document (as integer).
  203. *
  204. * @since 15.0.0
  205. *
  206. * @param string $option
  207. * @param int $value
  208. *
  209. * @return IIndex
  210. */
  211. public function addOptionInt(string $option, int $value): IIndex;
  212. /**
  213. * Get the option related to the original document (as string).
  214. *
  215. * @since 15.0.0
  216. *
  217. * @param string $option
  218. * @param string $default
  219. *
  220. * @return string
  221. */
  222. public function getOption(string $option, string $default = ''): string;
  223. /**
  224. * Get the option related to the original document (as integer).
  225. *
  226. * @since 15.0.0
  227. *
  228. * @param string $option
  229. * @param int $default
  230. *
  231. * @return int
  232. */
  233. public function getOptionInt(string $option, int $default = 0): int;
  234. /**
  235. * Get all options related to the original document.
  236. *
  237. * @since 15.0.0
  238. *
  239. * @return array
  240. */
  241. public function getOptions(): array;
  242. /**
  243. * Add an error log related to the Index.
  244. *
  245. * @since 15.0.0
  246. *
  247. * @param string $message
  248. * @param string $exception
  249. * @param int $sev
  250. *
  251. * @return IIndex
  252. */
  253. public function addError(string $message, string $exception = '', int $sev = self::ERROR_SEV_3): IIndex;
  254. /**
  255. * Returns the number of known errors related to the Index.
  256. *
  257. * @since 15.0.0
  258. *
  259. * @return int
  260. */
  261. public function getErrorCount(): int;
  262. /**
  263. * Reset all error logs related to the Index.
  264. *
  265. * @since 15.0.0
  266. */
  267. public function resetErrors(): IIndex;
  268. /**
  269. * Set the date of the last index.
  270. *
  271. * @since 15.0.0
  272. *
  273. * @param int $lastIndex
  274. *
  275. * @return IIndex
  276. */
  277. public function setLastIndex(int $lastIndex = -1): IIndex;
  278. /**
  279. * Get the date of the last index.
  280. *
  281. * @since 15.0.0
  282. *
  283. * @return int
  284. */
  285. public function getLastIndex(): int;
  286. }