public function testParsingCustomFragments() { $parser = new FragmentParser(); $body = ['query' => [new IDFilter(123)]]; $expectedBody = ['query' => [['term' => ['id' => 123]]]]; $this->assertEquals($expectedBody, $parser->parse($body)); }
/** * Build the query by adding all chunks together. * * @return array */ protected function buildQuery() { $this->setup(); $query = array(); // Index always needs to be provided. _all means a cross index search. $query['index'] = empty($this->indices) ? '_all' : implode(',', array_values($this->indices)); // Type is not required, will search in the entire index. if (!empty($this->types)) { $query['type'] = implode(',', array_values($this->types)); } // Replace Fragments with their raw body. $query['body'] = $this->fragmentParser->parse($this->body); return $query; }
/** * Build the query by adding all chunks together. * * @return array */ protected function buildQuery() { $this->setup(); $query = array(); // Index always needs to be provided. _all means a cross index search. $query['index'] = empty($this->indices) ? '_all' : implode(',', array_values($this->indices)); // Type is not required, will search in the entire index. if (!empty($this->types)) { $query['type'] = implode(',', array_values($this->types)); } // Replace Fragments with their raw body. $query['body'] = $this->fragmentParser->parse($this->body); // Add all query string params, the SDK will only add known params to the URL. foreach ($this->queryStringParams as $paramName => $paramValue) { $query[$paramName] = $paramValue; } return $query; }
/** * @return array */ public function getBody() { // Replace fragments with their raw body. return $this->fragmentParser->parse($this->body); }