code: public function index($document, $id=false, array $options = array()) {
          $url = $this->buildUrl(array($this->type, $id), $options);
          $method = ($id == false) ? "POST" : "PUT";
          return $this->call($url, $method, $document);
      }
docs: Index a new document or update it if existing
  
  @return array
  @param array $document
  @param mixed $id Optional
  @param array $options