1<?php 2 3namespace Elastica\Query; 4 5use Elastica\Document; 6 7/** 8 * Percolate query. 9 * 10 * @author Boris Popovschi <zyqsempai@mail.ru> 11 * 12 * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-percolate-query.html 13 */ 14/** 15 * Class Percolate. 16 */ 17class Percolate extends AbstractQuery 18{ 19 /** 20 * The field of type percolator and that holds the indexed queries. This is a required parameter. 21 * 22 * @return $this 23 */ 24 public function setField(string $field): self 25 { 26 return $this->setParam('field', $field); 27 } 28 29 /** 30 * The source of the document being percolated. 31 * 32 * @param array|Document $document 33 * 34 * @return $this 35 */ 36 public function setDocument($document): self 37 { 38 return $this->setParam('document', $document); 39 } 40 41 /** 42 * The index the document resides in. 43 * 44 * @return $this 45 */ 46 public function setDocumentIndex(string $index): self 47 { 48 return $this->setParam('index', $index); 49 } 50 51 /** 52 * The id of the document to fetch. 53 * 54 * @param int|string $id 55 * 56 * @return $this 57 */ 58 public function setDocumentId($id): self 59 { 60 return $this->setParam('id', $id); 61 } 62 63 /** 64 * Optionally, routing to be used to fetch document to percolate. 65 * 66 * @return $this 67 */ 68 public function setDocumentRouting(string $routing): self 69 { 70 return $this->setParam('routing', $routing); 71 } 72 73 /** 74 * Optionally, preference to be used to fetch document to percolate. 75 * 76 * @return $this 77 */ 78 public function setDocumentPreference(array $preference): self 79 { 80 return $this->setParam('preference', $preference); 81 } 82 83 /** 84 * Optionally, the expected version of the document to be fetched. 85 * 86 * @return $this 87 */ 88 public function setDocumentVersion(int $version): self 89 { 90 return $this->setParam('version', $version); 91 } 92} 93