title: Solr 400 Status: Bad Request
body: <p>I am trying to use solr PHP Client. When i tried to add the document it returning 400 status. I dont know what i am doing wrong and i am new to solr. Below is my code and schema.xml file. </p>
  
  <p>I am using solr 4.10.3 and tomcat 7</p>
  
  <p>Thanks in advance</p>
  
  <pre><code>$solr = new Apache_Solr_Service('localhost', '8080', '/solr/#/core0');    
  if (!$solr-&gt;ping()) {
  echo 'Solr service not responding.';
  exit;
  } else {
  $fileContent = $_GET['fileContent'];
  $title = trim($_GET['title']);
  $desription = $_GET['description'];
  $fileId = trim($_GET['fileId']);
  
  $docs = array(
      'doc1' =&gt; array(
          'id' =&gt; 1,
          'fileid' =&gt; 'file1',
          'title' =&gt; 'title1'
  ));
  
  $documents = array();
  $part = new Apache_Solr_Document();
  foreach ($docs as $item =&gt; $fields) {                
      foreach ($fields as $key =&gt; $value) {
          if (is_array($value)) {                        
              foreach ($value as $data) {
                  $part-&gt;setMultiValue($key, $data);
              }
          }                    
          else {                           
              $part-&gt;$key = $value;
          }
      }                  
  
      $documents[] = $part;
  }   
  // Load the documents into the index
  
  try {
      $a = $solr-&gt;addDocuments($documents);                
      $solr-&gt;commit();
      $solr-&gt;optimize();                    
  } catch (Exception $e) {
      echo $e-&gt;getMessage();
  }
  die;
  $offset = 0;
  $limit = 10;  
  
  $queries = array('id:'.$fileId);
  
  foreach ($queries as $query) {
      $response = $solr-&gt;search($query, $offset, $limit);
      if ($response-&gt;getHttpStatus() == 200) {
          // print_r( $response-&gt;getRawResponse() );
          if ($response-&gt;response-&gt;numFound &gt; 0) {
              echo "$query &lt;br /&gt;";
              foreach ($response-&gt;response-&gt;docs as $doc) {
                  echo "$doc-&gt;id $doc-&gt;title &lt;br /&gt;";
              }
              echo '&lt;br /&gt;';
          }
      } else {
          echo $response-&gt;getHttpStatusMessage();
      }
  }
  }
  }
  </code></pre>
  
  <p>schema.xml</p>
  
  <pre><code>&lt;schema name="example core zero" version="1.1"&gt;
    &lt;fieldtype name="string"  class="solr.StrField" sortMissingLast="true" omitNorms="true"/&gt;
    &lt;fieldType name="long" class="solr.TrieLongField" precisionStep="0" positionIncrementGap="0"/&gt;
    &lt;field name="_version_" type="long" indexed="true" stored="true"/&gt;
    &lt;field name="id" type="long" indexed="true" stored="true"/&gt;
    &lt;field name="fileid"    type="string"   indexed="true"  stored="true"  required="true"/&gt;
    &lt;field name="title"     type="string"   indexed="true"  stored="true" /&gt;
  
   &lt;uniqueKey&gt;id&lt;/uniqueKey&gt;
  
  &lt;/schema&gt;
  </code></pre>