IFullTextSearchManager.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright 2018, Maxence Lange <maxence@artificial-owl.com>
  5. *
  6. * @author Maxence Lange <maxence@artificial-owl.com>
  7. *
  8. * @license GNU AGPL version 3 or any later version
  9. *
  10. * This program is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Affero General Public License as
  12. * published by the Free Software Foundation, either version 3 of the
  13. * License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU Affero General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Affero General Public License
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. *
  23. */
  24. namespace OCP\FullTextSearch;
  25. use OCP\FullTextSearch\Model\IIndex;
  26. use OCP\FullTextSearch\Model\ISearchResult;
  27. use OCP\FullTextSearch\Service\IIndexService;
  28. use OCP\FullTextSearch\Service\IProviderService;
  29. use OCP\FullTextSearch\Service\ISearchService;
  30. /**
  31. * Interface IFullTextSearchManager
  32. *
  33. * Should be used to manage FullTextSearch from the app that contains your
  34. * Content Provider/Search Platform.
  35. *
  36. * @since 15.0.0
  37. *
  38. */
  39. interface IFullTextSearchManager {
  40. /**
  41. * Register a IProviderService.
  42. *
  43. * @since 15.0.0
  44. *
  45. * @param IProviderService $providerService
  46. */
  47. public function registerProviderService(IProviderService $providerService);
  48. /**
  49. * Register a IIndexService.
  50. *
  51. * @since 15.0.0
  52. *
  53. * @param IIndexService $indexService
  54. */
  55. public function registerIndexService(IIndexService $indexService);
  56. /**
  57. * Register a ISearchService.
  58. *
  59. * @since 15.0.0
  60. *
  61. * @param ISearchService $searchService
  62. */
  63. public function registerSearchService(ISearchService $searchService);
  64. /**
  65. * returns true is Full Text Search is available (app is present and Service
  66. * are registered)
  67. *
  68. * @since 16.0.0
  69. *
  70. * @return bool
  71. */
  72. public function isAvailable(): bool;
  73. /**
  74. * Add the Javascript API in the navigation page of an app.
  75. * Needed to replace the default search.
  76. *
  77. * @since 15.0.0
  78. */
  79. public function addJavascriptAPI();
  80. /**
  81. * Check if the provider $providerId is already indexed.
  82. *
  83. * @since 15.0.0
  84. *
  85. * @param string $providerId
  86. *
  87. * @return bool
  88. */
  89. public function isProviderIndexed(string $providerId): bool;
  90. /**
  91. * Retrieve an Index from the database, based on the Id of the Provider
  92. * and the Id of the Document
  93. *
  94. * @since 15.0.0
  95. *
  96. * @param string $providerId
  97. * @param string $documentId
  98. *
  99. * @return IIndex
  100. */
  101. public function getIndex(string $providerId, string $documentId): IIndex;
  102. /**
  103. * Create a new Index.
  104. *
  105. * This method must be called when a new document is created.
  106. *
  107. * @since 15.0.0
  108. *
  109. * @param string $providerId
  110. * @param string $documentId
  111. * @param string $userId
  112. * @param int $status
  113. *
  114. * @return IIndex
  115. */
  116. public function createIndex(string $providerId, string $documentId, string $userId, int $status = 0): IIndex;
  117. /**
  118. * Update the status of an Index. status is a bitflag, setting $reset to
  119. * true will reset the status to the value defined in the parameter.
  120. *
  121. * @since 15.0.0
  122. *
  123. * @param string $providerId
  124. * @param string $documentId
  125. * @param int $status
  126. * @param bool $reset
  127. */
  128. public function updateIndexStatus(string $providerId, string $documentId, int $status, bool $reset = false);
  129. /**
  130. * Update the status of an array of Index. status is a bit flag, setting $reset to
  131. * true will reset the status to the value defined in the parameter.
  132. *
  133. * @since 15.0.0
  134. *
  135. * @param string $providerId
  136. * @param array $documentIds
  137. * @param int $status
  138. * @param bool $reset
  139. */
  140. public function updateIndexesStatus(string $providerId, array $documentIds, int $status, bool $reset = false);
  141. /**
  142. * Update an array of Index.
  143. *
  144. * @since 15.0.0
  145. *
  146. * @param IIndex[] $indexes
  147. */
  148. public function updateIndexes(array $indexes);
  149. /**
  150. * Search using an array as request. If $userId is empty, will use the
  151. * current session.
  152. *
  153. * @see ISearchService::generateSearchRequest
  154. *
  155. * @since 15.0.0
  156. *
  157. * @param array $request
  158. * @param string $userId
  159. * @return ISearchResult[]
  160. */
  161. public function search(array $request, string $userId = ''): array;
  162. }