code: public function search($query, array $options = array()) {
          $result = false;
          if (is_array($query)) {
              /**
               * Array implies using the JSON query DSL
               */
              $arg = "_search";
              /**
               * $options may contain values like:
               * $options['routing'] = 'user123'
               * or
               * $options['preference'] = 'xyzabc123'
               */
              $url = $this->buildUrl(array($this->type, $arg), $options);
  
              $result = $this->call($url, "GET", $query);
          }
          elseif (is_string($query)) {
              /**
               * String based search means http query string search
               */
              $url = $this->buildUrl(array(
                  $this->type, "_search?q=" . $query
              ));
              $result = $this->call($url, "POST", $options);
          }
          else {
              /**
               * no http query string search
               */
              $url = $this->buildUrl(array(
                  $this->type, "_search?"
              ));
              $result = $this->call($url, "POST", $options);
          }
          return $result;
      }
docs: Search
  
  @return array
  @param array|string $query
  @param array $options