code: protected function mergeBoolQuery(array $query1, array $query2, $type)
      {
          if (empty($query2['bool'][$type])) {
              return $query1;
          } else {
              if (empty($query1['bool'][$type])) {
                  $query1['bool'][$type] = [];
              }
          }
  
          $query1['bool'][$type] = array_merge($query1['bool'][$type], $query2['bool'][$type]);
  
          return $query1;
      }
docs: Merges BOOL elasticsearch queries.
  
  @param array $query1
  @param array $query2
  @param string $type must, must_not, should
  @return array