title: Unable to CREATE PRIMARY INDEX for couchbase bucket. on UBUNTU 14.04
body: <p>I am trying to get data from couchbase bucket using laravel 4.2 . And facing issue related to PRIMARY INDEX. Below are the details. Can someone please suggest where I am doing wrong. Thanks. </p>
  
  <p>Controller: </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?php
  
  namespace App\Http\Controllers;
  
  use Illuminate\Http\Request;
  use App\Http\Requests;
  use CouchbaseCluster;
  
  class HomeController extends Controller {
  
      public function index() {
  
  
  //        phpinfo();die;
  
  //        
      $Cluster  =  New  CouchbaseCluster ( 'http://127.0.0.1:8091' ); 
      $Bucket = $Cluster-&gt;OpenBucket('beer-sample');
  
  // Retrieve a document
  
      Try {
          $Result = $Bucket-&gt;Get('21St_amendment_brewery_cafe');
      } Catch (Exception $E) {
          Echo "CouchbaseException:" . $E-&gt;getMessage() . " \ N ";
      }
      $doc = Json_decode($Result-&gt;Value, True);
      var_dump($doc);die;
      }
  
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>getting below error message: </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>CouchbaseException in CouchbaseBucket.class.php line 196:
  The key does not exist on the server</code></pre>
  </div>
  </div>
  </p>
  
  <p>Then I changed my controller code and ran it again. </p>
  
  <p>Controller(Updated): </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?php
  
  namespace App\Http\Controllers;
  
  use Illuminate\Http\Request;
  use App\Http\Requests;
  use CouchbaseCluster;
  
  class HomeController extends Controller {
  
      public function index() {
  
  
  //        phpinfo();die;
          $query = 'SELECT * FROM `beer-sample` limit 2';
          $res = \DB::connection()-&gt;bucket('beer-sample')-&gt;select($query);
          var_dump($res);die;
  
      }
  
  }</code></pre>
  </div>
  </div>
  
  Then I am getting this error. </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>QueryException in Connection.php line 673:
  No primary index on keyspace beer-sample. Use CREATE PRIMARY INDEX to create one. (SQL: SELECT * FROM `beer-sample` limit 2)</code></pre>
  </div>
  </div>
  </p>
  
  <p>It seems both errors are related to (PRIMARY) Key. So, I tried to create primary key from my controller and ./cbq . But cases are failing. Below are the details. </p>
  
  <p>Controller logic to create PRIMARY KEY: </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?php
  
  namespace App\Http\Controllers;
  
  use Illuminate\Http\Request;
  use App\Http\Requests;
  use CouchbaseCluster;
  
  class HomeController extends Controller {
  
      public function index() {
  
  
  //        phpinfo();die;
          $query = 'CREATE PRIMARY INDEX `beer-sample-primary-index` ON `beer-sample` USING GSI WITH {"defer_build":true};';
          $res = \DB::connection()-&gt;bucket('beer-sample')-&gt;select($query);
          var_dump($res);die;      
    }
  
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>Page is throwing below error: </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>QueryException in Connection.php line 673:
  GSI CreatePrimaryIndex() - cause: Fails to create index. There is no available index service that can process this request at this time. Index Service can be in bootstrap, recovery, or non-reachable. Please retry the operation at a later time. (SQL: CREATE PRIMARY INDEX `beer-sample-primary-index` ON `beer-sample` USING GSI WITH {"defer_build":true};)</code></pre>
  </div>
  </div>
  </p>
  
  <p>Query from ./cbq also thrown similar error. </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>srturaka@srturaka-pc:/opt/couchbase/bin$ ./cbq
  Couchbase query shell connected to http://localhost:8093/ . Type Ctrl-D to exit.
  cbq&gt; CREATE PRIMARY INDEX ON `beer-sample` USING GSI;
  {
      "requestID": "30239420-7dc2-4892-ba90-1ecf0474ba19",
      "signature": null,
      "results": [
      ],
      "errors": [
          {
              "code": 5000,
              "msg": "GSI CreatePrimaryIndex() - cause: Fails to create index.  There is no available index service that can process this request at this time. Index Service can be in bootstrap, recovery, or non-reachable. Please retry the operation at a later time."
          }
      ],
      "status": "errors",
      "metrics": {
          "elapsedTime": "10.005267815s",
          "executionTime": "10.005169082s",
          "resultCount": 0,
          "resultSize": 0,
          "errorCount": 1
      }
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>Please help me on how to create PRIMARY KEY for couchbase buckets. Let me know if more information is required. </p>
  
  <p><strong>EDIT</strong></p>
  
  <p><a href="https://i.stack.imgur.com/2StP6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2StP6.png" alt="enter image description here"></a></p>
  
  <p><strong>Server Node Screenshots</strong></p>
  
  <p><a href="https://i.stack.imgur.com/RfA9h.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RfA9h.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/bUqFW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bUqFW.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/w9wDZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/w9wDZ.png" alt="enter image description here"></a></p>