MatchPhrasePrefix.php 801 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. namespace Elastica\Query;
  3. /**
  4. * Match Phrase Prefix query.
  5. *
  6. * @author Jacques Moati <jacques@moati.net>
  7. * @author Tobias Schultze <http://tobion.de>
  8. *
  9. * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query-phrase-prefix.html
  10. */
  11. class MatchPhrasePrefix extends MatchPhrase
  12. {
  13. const DEFAULT_MAX_EXPANSIONS = 50;
  14. /**
  15. * Set field max expansions.
  16. *
  17. * Controls to how many prefixes the last term will be expanded (default 50).
  18. *
  19. * @param string $field
  20. * @param int $maxExpansions
  21. *
  22. * @return $this
  23. */
  24. public function setFieldMaxExpansions($field, $maxExpansions = self::DEFAULT_MAX_EXPANSIONS)
  25. {
  26. return $this->setFieldParam($field, 'max_expansions', (int) $maxExpansions);
  27. }
  28. }