PageRenderTime 45ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/vendor/solarium/solarium/library/Solarium/QueryType/Select/Query/Component/MoreLikeThis.php

https://gitlab.com/Blueprint-Marketing/solr-power
PHP | 341 lines | 116 code | 29 blank | 196 comment | 6 complexity | 90dea771c238daddd53d04e7bb4ddd36 MD5 | raw file
  1. <?php
  2. /**
  3. * Copyright 2011 Bas de Nooijer. All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. *
  8. * 1. Redistributions of source code must retain the above copyright notice,
  9. * this list of conditions and the following disclaimer.
  10. *
  11. * 2. Redistributions in binary form must reproduce the above copyright notice,
  12. * this listof conditions and the following disclaimer in the documentation
  13. * and/or other materials provided with the distribution.
  14. *
  15. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS"
  16. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  17. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  18. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
  19. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  20. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  21. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  22. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  23. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  24. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  25. * POSSIBILITY OF SUCH DAMAGE.
  26. *
  27. * The views and conclusions contained in the software and documentation are
  28. * those of the authors and should not be interpreted as representing official
  29. * policies, either expressed or implied, of the copyright holder.
  30. *
  31. * @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
  32. * @license http://github.com/basdenooijer/solarium/raw/master/COPYING
  33. * @link http://www.solarium-project.org/
  34. */
  35. /**
  36. * @namespace
  37. */
  38. namespace Solarium\QueryType\Select\Query\Component;
  39. use Solarium\QueryType\Select\Query\Query as SelectQuery;
  40. use Solarium\QueryType\Select\RequestBuilder\Component\MoreLikeThis as RequestBuilder;
  41. use Solarium\QueryType\Select\ResponseParser\Component\MoreLikeThis as ResponseParser;
  42. /**
  43. * MoreLikeThis component
  44. *
  45. * @link http://wiki.apache.org/solr/MoreLikeThis
  46. */
  47. class MoreLikeThis extends Component
  48. {
  49. /**
  50. * Get component type
  51. *
  52. * @return string
  53. */
  54. public function getType()
  55. {
  56. return SelectQuery::COMPONENT_MORELIKETHIS;
  57. }
  58. /**
  59. * Get a requestbuilder for this query
  60. *
  61. * @return RequestBuilder
  62. */
  63. public function getRequestBuilder()
  64. {
  65. return new RequestBuilder;
  66. }
  67. /**
  68. * Get a response parser for this query
  69. *
  70. * @return ResponseParser
  71. */
  72. public function getResponseParser()
  73. {
  74. return new ResponseParser;
  75. }
  76. /**
  77. * Set fields option
  78. *
  79. * The fields to use for similarity. NOTE: if possible, these should have a
  80. * stored TermVector
  81. *
  82. * When using string input you can separate multiple fields with commas.
  83. *
  84. * @param string|array $fields
  85. * @return self Provides fluent interface
  86. */
  87. public function setFields($fields)
  88. {
  89. if (is_string($fields)) {
  90. $fields = explode(',', $fields);
  91. $fields = array_map('trim', $fields);
  92. }
  93. return $this->setOption('fields', $fields);
  94. }
  95. /**
  96. * Get fields option
  97. *
  98. * @return array
  99. */
  100. public function getFields()
  101. {
  102. $fields = $this->getOption('fields');
  103. if ($fields == null) {
  104. $fields = array();
  105. }
  106. return $fields;
  107. }
  108. /**
  109. * Set minimumtermfrequency option
  110. *
  111. * Minimum Term Frequency - the frequency below which terms will be ignored
  112. * in the source doc.
  113. *
  114. * @param int $minimum
  115. * @return self Provides fluent interface
  116. */
  117. public function setMinimumTermFrequency($minimum)
  118. {
  119. return $this->setOption('minimumtermfrequency', $minimum);
  120. }
  121. /**
  122. * Get minimumtermfrequency option
  123. *
  124. * @return integer|null
  125. */
  126. public function getMinimumTermFrequency()
  127. {
  128. return $this->getOption('minimumtermfrequency');
  129. }
  130. /**
  131. * Set minimumdocumentfrequency option
  132. *
  133. * Minimum Document Frequency - the frequency at which words will be
  134. * ignored which do not occur in at least this many docs.
  135. *
  136. * @param int $minimum
  137. * @return self Provides fluent interface
  138. */
  139. public function setMinimumDocumentFrequency($minimum)
  140. {
  141. return $this->setOption('minimumdocumentfrequency', $minimum);
  142. }
  143. /**
  144. * Get minimumdocumentfrequency option
  145. *
  146. * @return integer|null
  147. */
  148. public function getMinimumDocumentFrequency()
  149. {
  150. return $this->getOption('minimumdocumentfrequency');
  151. }
  152. /**
  153. * Set minimumwordlength option
  154. *
  155. * Minimum word length below which words will be ignored.
  156. *
  157. * @param int $minimum
  158. * @return self Provides fluent interface
  159. */
  160. public function setMinimumWordLength($minimum)
  161. {
  162. return $this->setOption('minimumwordlength', $minimum);
  163. }
  164. /**
  165. * Get minimumwordlength option
  166. *
  167. * @return integer|null
  168. */
  169. public function getMinimumWordLength()
  170. {
  171. return $this->getOption('minimumwordlength');
  172. }
  173. /**
  174. * Set maximumwordlength option
  175. *
  176. * Maximum word length above which words will be ignored.
  177. *
  178. * @param int $maximum
  179. * @return self Provides fluent interface
  180. */
  181. public function setMaximumWordLength($maximum)
  182. {
  183. return $this->setOption('maximumwordlength', $maximum);
  184. }
  185. /**
  186. * Get maximumwordlength option
  187. *
  188. * @return integer|null
  189. */
  190. public function getMaximumWordLength()
  191. {
  192. return $this->getOption('maximumwordlength');
  193. }
  194. /**
  195. * Set maximumqueryterms option
  196. *
  197. * Maximum number of query terms that will be included in any generated
  198. * query.
  199. *
  200. * @param int $maximum
  201. * @return self Provides fluent interface
  202. */
  203. public function setMaximumQueryTerms($maximum)
  204. {
  205. return $this->setOption('maximumqueryterms', $maximum);
  206. }
  207. /**
  208. * Get maximumqueryterms option
  209. *
  210. * @return integer|null
  211. */
  212. public function getMaximumQueryTerms()
  213. {
  214. return $this->getOption('maximumqueryterms');
  215. }
  216. /**
  217. * Set maximumnumberoftokens option
  218. *
  219. * Maximum number of tokens to parse in each example doc field that is not
  220. * stored with TermVector support.
  221. *
  222. * @param int $maximum
  223. * @return self Provides fluent interface
  224. */
  225. public function setMaximumNumberOfTokens($maximum)
  226. {
  227. return $this->setOption('maximumnumberoftokens', $maximum);
  228. }
  229. /**
  230. * Get maximumnumberoftokens option
  231. *
  232. * @return integer|null
  233. */
  234. public function getMaximumNumberOfTokens()
  235. {
  236. return $this->getOption('maximumnumberoftokens');
  237. }
  238. /**
  239. * Set boost option
  240. *
  241. * If true the query will be boosted by the interesting term relevance.
  242. *
  243. * @param boolean $boost
  244. * @return self Provides fluent interface
  245. */
  246. public function setBoost($boost)
  247. {
  248. return $this->setOption('boost', $boost);
  249. }
  250. /**
  251. * Get boost option
  252. *
  253. * @return boolean|null
  254. */
  255. public function getBoost()
  256. {
  257. return $this->getOption('boost');
  258. }
  259. /**
  260. * Set queryfields option
  261. *
  262. * Query fields and their boosts using the same format as that used in
  263. * DisMaxQParserPlugin. These fields must also be specified in fields.
  264. *
  265. * When using string input you can separate multiple fields with commas.
  266. *
  267. * @param string $queryFields
  268. * @return self Provides fluent interface
  269. */
  270. public function setQueryFields($queryFields)
  271. {
  272. if (is_string($queryFields)) {
  273. $queryFields = explode(',', $queryFields);
  274. $queryFields = array_map('trim', $queryFields);
  275. }
  276. return $this->setOption('queryfields', $queryFields);
  277. }
  278. /**
  279. * Get queryfields option
  280. *
  281. * @return array
  282. */
  283. public function getQueryFields()
  284. {
  285. $queryfields = $this->getOption('queryfields');
  286. if ($queryfields == null) {
  287. $queryfields = array();
  288. }
  289. return $queryfields;
  290. }
  291. /**
  292. * Set count option
  293. *
  294. * The number of similar documents to return for each result
  295. *
  296. * @param int $count
  297. * @return self Provides fluent interface
  298. */
  299. public function setCount($count)
  300. {
  301. return $this->setOption('count', $count);
  302. }
  303. /**
  304. * Get count option
  305. *
  306. * @return int|null
  307. */
  308. public function getCount()
  309. {
  310. return $this->getOption('count');
  311. }
  312. }