ISearchResult.php 3.3 KB

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