code: public function mergeQuery(array $query)
      {
          $types = [
              Filter::MERGE_AND => 'must',
              Filter::MERGE_OR => 'should'
          ];
  
          $type = $this->getMergeType();
  
          $query['body']['filter']['bool'][$types[$type]][] = $this->makeQuery();
  
          return $query;
      }
docs: Merges elastcisearch query with current filter query.
  
  @param array $query Elastcisearch query.
  @return array Merged elasticsearch query.