1<?php 2 3namespace Elastica\QueryBuilder\DSL; 4 5use Elastica\QueryBuilder\DSL; 6use Elastica\Suggest\Completion; 7use Elastica\Suggest\Phrase; 8use Elastica\Suggest\Term; 9 10/** 11 * elasticsearch suggesters DSL. 12 * 13 * @author Manuel Andreo Garcia <andreo.garcia@googlemail.com> 14 * 15 * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters.html 16 */ 17class Suggest implements DSL 18{ 19 /** 20 * must return type for QueryBuilder usage. 21 */ 22 public function getType(): string 23 { 24 return self::TYPE_SUGGEST; 25 } 26 27 /** 28 * term suggester. 29 * 30 * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters-term.html 31 */ 32 public function term(string $name, string $field): Term 33 { 34 return new Term($name, $field); 35 } 36 37 /** 38 * phrase suggester. 39 * 40 * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters-phrase.html 41 */ 42 public function phrase(string $name, string $field): Phrase 43 { 44 return new Phrase($name, $field); 45 } 46 47 /** 48 * completion suggester. 49 * 50 * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters-completion.html 51 */ 52 public function completion(string $name, string $field): Completion 53 { 54 return new Completion($name, $field); 55 } 56} 57