diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2015-12-17 09:15:42 +0100 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2015-12-17 09:44:51 +0100 |
commit | a1789ddde42033f1b05cc4929491214ee6e79383 (patch) | |
tree | 63615735c4ddffaaabf2428946bb26f90899f7bf /vendor/ruflin/elastica/lib/Elastica/Suggest/CandidateGenerator | |
parent | 9e06a62f265e3a2aaabecc598d4bc617e06fa32d (diff) |
Update to MediaWiki 1.26.0
Diffstat (limited to 'vendor/ruflin/elastica/lib/Elastica/Suggest/CandidateGenerator')
2 files changed, 148 insertions, 0 deletions
diff --git a/vendor/ruflin/elastica/lib/Elastica/Suggest/CandidateGenerator/AbstractCandidateGenerator.php b/vendor/ruflin/elastica/lib/Elastica/Suggest/CandidateGenerator/AbstractCandidateGenerator.php new file mode 100644 index 00000000..6fba49db --- /dev/null +++ b/vendor/ruflin/elastica/lib/Elastica/Suggest/CandidateGenerator/AbstractCandidateGenerator.php @@ -0,0 +1,8 @@ +<?php +namespace Elastica\Suggest\CandidateGenerator; + +use Elastica\Param; + +class AbstractCandidateGenerator extends Param +{ +} diff --git a/vendor/ruflin/elastica/lib/Elastica/Suggest/CandidateGenerator/DirectGenerator.php b/vendor/ruflin/elastica/lib/Elastica/Suggest/CandidateGenerator/DirectGenerator.php new file mode 100644 index 00000000..54ac7649 --- /dev/null +++ b/vendor/ruflin/elastica/lib/Elastica/Suggest/CandidateGenerator/DirectGenerator.php @@ -0,0 +1,140 @@ +<?php +namespace Elastica\Suggest\CandidateGenerator; + +/** + * Class DirectGenerator. + * + * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters-phrase.html#_direct_generators + */ +class DirectGenerator extends AbstractCandidateGenerator +{ + const SUGGEST_MODE_MISSING = 'missing'; + const SUGGEST_MODE_POPULAR = 'popular'; + const SUGGEST_MODE_ALWAYS = 'always'; + + /** + * @param string $field + */ + public function __construct($field) + { + $this->setField($field); + } + + /** + * Set the field name from which to fetch candidate suggestions. + * + * @param string $field + * + * @return $this + */ + public function setField($field) + { + return $this->setParam('field', $field); + } + + /** + * Set the maximum corrections to be returned per suggest text token. + * + * @param int $size + * + * @return $this + */ + public function setSize($size) + { + return $this->setParam('size', $size); + } + + /** + * @param string $mode see SUGGEST_MODE_* constants for options + * + * @return $this + */ + public function setSuggestMode($mode) + { + return $this->setParam('suggest_mode', $mode); + } + + /** + * @param int $max can only be a value between 1 and 2. Defaults to 2. + * + * @return $this + */ + public function setMaxEdits($max) + { + return $this->setParam('max_edits', $max); + } + + /** + * @param int $length defaults to 1 + * + * @return $this + */ + public function setPrefixLength($length) + { + return $this->setParam('prefix_len', $length); + } + + /** + * @param int $min defaults to 4 + * + * @return $this + */ + public function setMinWordLength($min) + { + return $this->setParam('min_word_len', $min); + } + + /** + * @param int $max + * + * @return $this + */ + public function setMaxInspections($max) + { + return $this->setParam('max_inspections', $max); + } + + /** + * @param float $min + * + * @return $this + */ + public function setMinDocFrequency($min) + { + return $this->setParam('min_doc_freq', $min); + } + + /** + * @param float $max + * + * @return $this + */ + public function setMaxTermFrequency($max) + { + return $this->setParam('max_term_freq', $max); + } + + /** + * Set an analyzer to be applied to the original token prior to candidate generation. + * + * @param string $pre an analyzer + * + * @return $this + */ + public function setPreFilter($pre) + { + return $this->setParam('pre_filter', $pre); + } + + /** + * Set an analyzer to be applied to generated tokens before they are passed to the phrase scorer. + * + * @param string $post + * + * @return $this + */ + public function setPostFilter($post) + { + return $this->setParam('post_filter', $post); + } +} |