Percolate.php 2.2 KB

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