IFullTextSearchManager.php 4.4 KB

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