ISearchRequest.php 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  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. /**
  9. * Interface ISearchRequest
  10. *
  11. * When a search request is initiated, from a request from the front-end or using
  12. * the IFullTextSearchManager::search() method, FullTextSearch will create a
  13. * SearchRequest object, based on this interface.
  14. *
  15. * The object will be passed to the targeted Content Provider so it can convert
  16. * search options using available method.
  17. *
  18. * The object is then encapsulated in a SearchResult and send to the
  19. * Search Platform.
  20. *
  21. * @since 15.0.0
  22. *
  23. *
  24. */
  25. interface ISearchRequest {
  26. /**
  27. * Get the maximum number of results to be returns by the Search Platform.
  28. *
  29. * @since 15.0.0
  30. *
  31. * @return int
  32. */
  33. public function getSize(): int;
  34. /**
  35. * Get the current page.
  36. * Used by pagination.
  37. *
  38. * @since 15.0.0
  39. *
  40. * @return int
  41. */
  42. public function getPage(): int;
  43. /**
  44. * Get the author of the request.
  45. *
  46. * @since 15.0.0
  47. *
  48. * @return string
  49. */
  50. public function getAuthor(): string;
  51. /**
  52. * Get the searched string.
  53. *
  54. * @since 15.0.0
  55. *
  56. * @return string
  57. */
  58. public function getSearch(): string;
  59. /**
  60. * Set the searched string.
  61. *
  62. * @param string $search
  63. *
  64. * @since 17.0.0
  65. *
  66. * @return ISearchRequest
  67. */
  68. public function setSearch(string $search): ISearchRequest;
  69. /**
  70. * Extends the searched string.
  71. *
  72. * @since 17.0.0
  73. *
  74. * @param string $search
  75. *
  76. * @return ISearchRequest
  77. */
  78. public function addSearch(string $search): ISearchRequest;
  79. /**
  80. * Get the value of an option (as string).
  81. *
  82. * @since 15.0.0
  83. *
  84. * @param string $option
  85. * @param string $default
  86. *
  87. * @return string
  88. */
  89. public function getOption(string $option, string $default = ''): string;
  90. /**
  91. * Get the value of an option (as array).
  92. *
  93. * @since 15.0.0
  94. *
  95. * @param string $option
  96. * @param array $default
  97. *
  98. * @return array
  99. */
  100. public function getOptionArray(string $option, array $default = []): array;
  101. /**
  102. * Limit the search to a part of the document.
  103. *
  104. * @since 15.0.0
  105. *
  106. * @param string $part
  107. *
  108. * @return ISearchRequest
  109. */
  110. public function addPart(string $part): ISearchRequest;
  111. /**
  112. * Limit the search to an array of parts of the document.
  113. *
  114. * @since 15.0.0
  115. *
  116. * @param array $parts
  117. *
  118. * @return ISearchRequest
  119. */
  120. public function setParts(array $parts): ISearchRequest;
  121. /**
  122. * Get the parts the search is limited to.
  123. *
  124. * @since 15.0.0
  125. *
  126. * @return array
  127. */
  128. public function getParts(): array;
  129. /**
  130. * Limit the search to a specific meta tag.
  131. *
  132. * @since 15.0.0
  133. *
  134. * @param string $tag
  135. *
  136. * @return ISearchRequest
  137. */
  138. public function addMetaTag(string $tag): ISearchRequest;
  139. /**
  140. * Get the meta tags the search is limited to.
  141. *
  142. * @since 15.0.0
  143. *
  144. * @return array
  145. */
  146. public function getMetaTags(): array;
  147. /**
  148. * Limit the search to an array of meta tags.
  149. *
  150. * @since 15.0.0
  151. *
  152. * @param array $tags
  153. *
  154. * @return ISearchRequest
  155. */
  156. public function setMetaTags(array $tags): ISearchRequest;
  157. /**
  158. * Limit the search to a specific sub tag.
  159. *
  160. * @since 15.0.0
  161. *
  162. * @param string $source
  163. * @param string $tag
  164. *
  165. * @return ISearchRequest
  166. */
  167. public function addSubTag(string $source, string $tag): ISearchRequest;
  168. /**
  169. * Get the sub tags the search is limited to.
  170. *
  171. * @since 15.0.0
  172. *
  173. * @param bool $formatted
  174. *
  175. * @return array
  176. */
  177. public function getSubTags(bool $formatted): array;
  178. /**
  179. * Limit the search to an array of sub tags.
  180. *
  181. * @since 15.0.0
  182. *
  183. * @param array $tags
  184. *
  185. * @return ISearchRequest
  186. */
  187. public function setSubTags(array $tags): ISearchRequest;
  188. /**
  189. * Limit the search to a specific field of the mapping, using a full string.
  190. *
  191. * @since 15.0.0
  192. *
  193. * @param string $field
  194. *
  195. * @return ISearchRequest
  196. */
  197. public function addLimitField(string $field): ISearchRequest;
  198. /**
  199. * Get the fields the search is limited to.
  200. *
  201. * @since 15.0.0
  202. *
  203. * @return array
  204. */
  205. public function getLimitFields(): array;
  206. /**
  207. * Limit the search to a specific field of the mapping, using a wildcard on
  208. * the search string.
  209. *
  210. * @since 15.0.0
  211. *
  212. * @param string $field
  213. *
  214. * @return ISearchRequest
  215. */
  216. public function addWildcardField(string $field): ISearchRequest;
  217. /**
  218. * Get the limit to field of the mapping.
  219. *
  220. * @since 15.0.0
  221. *
  222. * @return array
  223. */
  224. public function getWildcardFields(): array;
  225. /**
  226. * Filter the results, based on a group of field, using regex
  227. *
  228. * @since 15.0.0
  229. *
  230. * @param array $filters
  231. *
  232. * @return ISearchRequest
  233. */
  234. public function addRegexFilters(array $filters): ISearchRequest;
  235. /**
  236. * Get the regex filters the search is limit to.
  237. *
  238. * @since 15.0.0
  239. *
  240. * @return array
  241. */
  242. public function getRegexFilters(): array;
  243. /**
  244. * Filter the results, based on a group of field, using wildcard
  245. *
  246. * @since 15.0.0
  247. *
  248. * @param array $filter
  249. *
  250. * @return ISearchRequest
  251. */
  252. public function addWildcardFilter(array $filter): ISearchRequest;
  253. /**
  254. * Get the wildcard filters the search is limit to.
  255. *
  256. * @since 15.0.0
  257. *
  258. * @return array
  259. */
  260. public function getWildcardFilters(): array;
  261. /**
  262. * Add an extra field to the search.
  263. *
  264. * @since 15.0.0
  265. *
  266. * @param string $field
  267. *
  268. * @return ISearchRequest
  269. */
  270. public function addField(string $field): ISearchRequest;
  271. /**
  272. * Get the list of extra field to search into.
  273. *
  274. * @since 15.0.0
  275. *
  276. * @return array
  277. */
  278. public function getFields(): array;
  279. /**
  280. * Add a MUST search on an extra field
  281. *
  282. * @param ISearchRequestSimpleQuery $query
  283. *
  284. * @return ISearchRequest
  285. * @since 17.0.0
  286. */
  287. public function addSimpleQuery(ISearchRequestSimpleQuery $query): ISearchRequest;
  288. /**
  289. * Get the list of queries on extra field.
  290. *
  291. * @return ISearchRequestSimpleQuery[]
  292. * @since 17.0.0
  293. */
  294. public function getSimpleQueries(): array;
  295. }