original_string: protected function add_solr_document($doc) {
          $solrdoc = new \SolrInputDocument();
          foreach ($doc as $field => $value) {
              $solrdoc->addField($field, $value);
          }
  
          try {
              $result = $this->get_search_client()->addDocument($solrdoc, true, static::AUTOCOMMIT_WITHIN);
              return true;
          } catch (\SolrClientException $e) {
              debugging('Solr client error adding document with id ' . $doc['id'] . ': ' . $e->getMessage(), DEBUG_DEVELOPER);
          } catch (\SolrServerException $e) {
              // We only use the first line of the message, as it's a fully java stacktrace behind it.
              $msg = strtok($e->getMessage(), "\n");
              debugging('Solr server error adding document with id ' . $doc['id'] . ': ' . $msg, DEBUG_DEVELOPER);
          }
  
          return false;
      }
code: protected function add_solr_document($doc) {
          $solrdoc = new \SolrInputDocument();
          foreach ($doc as $field => $value) {
              $solrdoc->addField($field, $value);
          }
  
          try {
              $result = $this->get_search_client()->addDocument($solrdoc, true, static::AUTOCOMMIT_WITHIN);
              return true;
          } catch (\SolrClientException $e) {
              debugging('Solr client error adding document with id ' . $doc['id'] . ': ' . $e->getMessage(), DEBUG_DEVELOPER);
          } catch (\SolrServerException $e) {
              // We only use the first line of the message, as it's a fully java stacktrace behind it.
              $msg = strtok($e->getMessage(), "\n");
              debugging('Solr server error adding document with id ' . $doc['id'] . ': ' . $msg, DEBUG_DEVELOPER);
          }
  
          return false;
      }
code_tokens: protected function add_solr_document ( $ doc ) { $ solrdoc = new \ SolrInputDocument ( ) ; foreach ( $ doc as $ field => $ value ) { $ solrdoc -> addField ( $ field , $ value ) ; } try { $ result = $ this -> get_search_client ( ) -> addDocument ( $ solrdoc , true , static :: AUTOCOMMIT_WITHIN ) ; return true ; } catch ( \ SolrClientException $ e ) { debugging ( 'Solr client error adding document with id ' . $ doc [ 'id' ] . ': ' . $ e -> getMessage ( ) , DEBUG_DEVELOPER ) ; } catch ( \ SolrServerException $ e ) { // We only use the first line of the message, as it's a fully java stacktrace behind it. $ msg = strtok ( $ e -> getMessage ( ) , "\n" ) ; debugging ( 'Solr server error adding document with id ' . $ doc [ 'id' ] . ': ' . $ msg , DEBUG_DEVELOPER ) ; } return false ; }
docstring: Adds a text document to the search engine.
  
  @param array $doc
  @return bool
docstring_tokens: Adds a text document to the search engine .