1
0

ISearchRequest.php 6.0 KB

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