IFullTextSearchManager.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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;
  8. use OCP\FullTextSearch\Model\IIndex;
  9. use OCP\FullTextSearch\Model\ISearchResult;
  10. use OCP\FullTextSearch\Service\IIndexService;
  11. use OCP\FullTextSearch\Service\IProviderService;
  12. use OCP\FullTextSearch\Service\ISearchService;
  13. /**
  14. * Interface IFullTextSearchManager
  15. *
  16. * Should be used to manage FullTextSearch from the app that contains your
  17. * Content Provider/Search Platform.
  18. *
  19. * @since 15.0.0
  20. *
  21. */
  22. interface IFullTextSearchManager {
  23. /**
  24. * Register a IProviderService.
  25. *
  26. * @since 15.0.0
  27. *
  28. * @param IProviderService $providerService
  29. */
  30. public function registerProviderService(IProviderService $providerService);
  31. /**
  32. * Register a IIndexService.
  33. *
  34. * @since 15.0.0
  35. *
  36. * @param IIndexService $indexService
  37. */
  38. public function registerIndexService(IIndexService $indexService);
  39. /**
  40. * Register a ISearchService.
  41. *
  42. * @since 15.0.0
  43. *
  44. * @param ISearchService $searchService
  45. */
  46. public function registerSearchService(ISearchService $searchService);
  47. /**
  48. * returns true is Full Text Search is available (app is present and Service
  49. * are registered)
  50. *
  51. * @since 16.0.0
  52. *
  53. * @return bool
  54. */
  55. public function isAvailable(): bool;
  56. /**
  57. * Add the Javascript API in the navigation page of an app.
  58. * Needed to replace the default search.
  59. *
  60. * @since 15.0.0
  61. */
  62. public function addJavascriptAPI();
  63. /**
  64. * Check if the provider $providerId is already indexed.
  65. *
  66. * @since 15.0.0
  67. *
  68. * @param string $providerId
  69. *
  70. * @return bool
  71. */
  72. public function isProviderIndexed(string $providerId): bool;
  73. /**
  74. * Retrieve an Index from the database, based on the Id of the Provider
  75. * and the Id of the Document
  76. *
  77. * @since 15.0.0
  78. *
  79. * @param string $providerId
  80. * @param string $documentId
  81. *
  82. * @return IIndex
  83. */
  84. public function getIndex(string $providerId, string $documentId): IIndex;
  85. /**
  86. * Create a new Index.
  87. *
  88. * This method must be called when a new document is created.
  89. *
  90. * @since 15.0.0
  91. *
  92. * @param string $providerId
  93. * @param string $documentId
  94. * @param string $userId
  95. * @param int $status
  96. *
  97. * @return IIndex
  98. */
  99. public function createIndex(string $providerId, string $documentId, string $userId, int $status = 0): IIndex;
  100. /**
  101. * Update the status of an Index. status is a bitflag, setting $reset to
  102. * true will reset the status to the value defined in the parameter.
  103. *
  104. * @since 15.0.0
  105. *
  106. * @param string $providerId
  107. * @param string $documentId
  108. * @param int $status
  109. * @param bool $reset
  110. */
  111. public function updateIndexStatus(string $providerId, string $documentId, int $status, bool $reset = false);
  112. /**
  113. * Update the status of an array of Index. status is a bit flag, 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 array $documentIds
  120. * @param int $status
  121. * @param bool $reset
  122. */
  123. public function updateIndexesStatus(string $providerId, array $documentIds, int $status, bool $reset = false);
  124. /**
  125. * Update an array of Index.
  126. *
  127. * @since 15.0.0
  128. *
  129. * @param IIndex[] $indexes
  130. */
  131. public function updateIndexes(array $indexes);
  132. /**
  133. * Search using an array as request. If $userId is empty, will use the
  134. * current session.
  135. *
  136. * @see ISearchService::generateSearchRequest
  137. *
  138. * @since 15.0.0
  139. *
  140. * @param array $request
  141. * @param string $userId
  142. * @return ISearchResult[]
  143. */
  144. public function search(array $request, string $userId = ''): array;
  145. }