1
0

ISearchResult.php 3.9 KB

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