3 class PhabricatorElasticsearchQueryBuilder
{
5 protected $clauses = array();
8 public function getClauses($termkey = null) {
9 $clauses = $this->clauses
;
10 if ($termkey == null) {
13 if (isset($clauses[$termkey])) {
14 return $clauses[$termkey];
19 public function getClauseCount($clausekey) {
20 if (isset($this->clauses
[$clausekey])) {
21 return count($this->clauses
[$clausekey]);
27 public function addExistsClause($field) {
28 return $this->addClause('filter', array(
35 public function addTermsClause($field, $values) {
36 return $this->addClause('filter', array(
38 $field => array_values($values),
43 public function addMustClause($clause) {
44 return $this->addClause('must', $clause);
47 public function addFilterClause($clause) {
48 return $this->addClause('filter', $clause);
51 public function addShouldClause($clause) {
52 return $this->addClause('should', $clause);
55 public function addMustNotClause($clause) {
56 return $this->addClause('must_not', $clause);
59 public function addClause($clause, $terms) {
60 $this->clauses
[$clause][] = $terms;
64 public function toArray() {
65 $clauses = $this->getClauses();
68 foreach ($clauses as $clause => $subclauses) {
69 if (is_array($subclauses) && count($subclauses) == 1) {
70 $cleaned[$clause] = array_shift($subclauses);
72 $cleaned[$clause] = $subclauses;