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.

360 lines
6.6 KiB

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