You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ISearchResult.php 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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
  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\Model;
  28. use OCP\FullTextSearch\IFullTextSearchProvider;
  29. /**
  30. * Interface ISearchResult
  31. *
  32. * When a search request is initiated, FullTextSearch will create a SearchResult
  33. * object, based on this interface, containing the SearchRequest and the targeted
  34. * Content Provider.
  35. *
  36. * The object will be passed to the Search Platform, which will proceed to the
  37. * search and fill the SearchResult object with results.
  38. *
  39. * Then, the object will be passed to the targeted Content Provider that will
  40. * improve the Search Results with detailed informations.
  41. *
  42. * Finally, the SearchResult is returned to the original search request.
  43. *
  44. * @since 15.0.0
  45. *
  46. * @package OCP\FullTextSearch\Model
  47. */
  48. interface ISearchResult {
  49. /**
  50. * Get the original SearchRequest.
  51. *
  52. * @see ISearchRequest
  53. *
  54. * @since 15.0.0
  55. *
  56. * @return ISearchRequest
  57. */
  58. public function getRequest(): ISearchRequest;
  59. /**
  60. * Get the targeted Content Provider.
  61. *
  62. * @since 15.0.0
  63. *
  64. * @return IFullTextSearchProvider
  65. */
  66. public function getProvider(): IFullTextSearchProvider;
  67. /**
  68. * Add an IndexDocument as one of the result of the search request.
  69. *
  70. * @since 15.0.0
  71. *
  72. * @param IndexDocument $document
  73. *
  74. * @return ISearchResult
  75. */
  76. public function addDocument(IndexDocument $document): ISearchResult;
  77. /**
  78. * Returns all result of the search request, in an array of IndexDocument.
  79. *
  80. * @since 15.0.0
  81. *
  82. * @return array
  83. */
  84. public function getDocuments(): array;
  85. /**
  86. * Set an array of IndexDocument as the result of the search request.
  87. *
  88. * @since 15.0.0
  89. *
  90. * @param IndexDocument[] $documents
  91. *
  92. * @return ISearchResult
  93. */
  94. public function setDocuments(array $documents): ISearchResult;
  95. /**
  96. * Add an aggregation to the result.
  97. *
  98. * @since 15.0.0
  99. *
  100. * @param string $category
  101. * @param string $value
  102. * @param int $count
  103. *
  104. * @return ISearchResult
  105. */
  106. public function addAggregation(string $category, string $value, int $count): ISearchResult;
  107. /**
  108. * Get all aggregations.
  109. *
  110. * @since 15.0.0
  111. *
  112. * @param string $category
  113. *
  114. * @return array
  115. */
  116. public function getAggregations(string $category): array;
  117. /**
  118. * Set the raw result of the request.
  119. *
  120. * @since 15.0.0
  121. *
  122. * @param string $result
  123. *
  124. * @return ISearchResult
  125. */
  126. public function setRawResult(string $result): ISearchResult;
  127. /**
  128. * Set the total number of results for the search request.
  129. * Used by pagination.
  130. *
  131. * @since 15.0.0
  132. *
  133. * @param int $total
  134. *
  135. * @return ISearchResult
  136. */
  137. public function setTotal(int $total): ISearchResult;
  138. /**
  139. * Set the top score for the search request.
  140. *
  141. * @since 15.0.0
  142. *
  143. * @param int $score
  144. *
  145. * @return ISearchResult
  146. */
  147. public function setMaxScore(int $score): ISearchResult;
  148. /**
  149. * Set the time spent by the request to perform the search.
  150. *
  151. * @since 15.0.0
  152. *
  153. * @param int $time
  154. *
  155. * @return ISearchResult
  156. */
  157. public function setTime(int $time): ISearchResult;
  158. /**
  159. * Set to true if the request timed out.
  160. *
  161. * @since 15.0.0
  162. *
  163. * @param bool $timedOut
  164. *
  165. * @return ISearchResult
  166. */
  167. public function setTimedOut(bool $timedOut): ISearchResult;
  168. }