# Index Error with Ruby Client

**URL:** <https://discuss.aerospike.com/t/index-error-with-ruby-client/2390>\
**Category:** Ruby Client\
**Created:** [January 14, 2016, 8:01am UTC](https://discuss.aerospike.com/t/index-error-with-ruby-client/2390 "2016-01-14T08:01:54Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anand\_Mahajan](https://avatars.discourse-cdn.com/v4/letter/a/ed8c4c/32.png) [@Anand\_Mahajan](https://discuss.aerospike.com/u/Anand_Mahajan)\
**Post date:** [January 14, 2016, 8:01am UTC](https://discuss.aerospike.com/t/index-error-with-ruby-client/2390/1 "2016-01-14T08:01:55Z")

</div>

Have a strange error with the index query - the Ruby code snippet below -

```ruby
stmt = Statement.new("marketcheck", "listings", ["id", "price", "miles", "scraped_at", "status_date", "is_searchable_is", "seller_name", "source", "group_id", "grouped_at", "zip", "is_grouped", "touch_count", "is_duplicate"])
stmt.filters << Filter.Equal("vin", vin)
rs = aerospike_client.query(stmt)
listings = []
rs.each do |rec|
   puts rec
end
return listings

```

It returns an error as follows -

```auto
Aerospike::Exceptions::Aerospike: Index error
from /home/anand/.rvm/gems/ruby-2.1.5/gems/aerospike-1.0.11/lib/aerospike/query/stream_command.rb:47:in `parse_record_results'
from /home/anand/.rvm/gems/ruby-2.1.5/gems/aerospike-1.0.11/lib/aerospike/command/batch_command.rb:51:in `parse_result'
from /home/anand/.rvm/gems/ruby-2.1.5/gems/aerospike-1.0.11/lib/aerospike/command/command.rb:454:in `execute'
from /home/anand/.rvm/gems/ruby-2.1.5/gems/aerospike-1.0.11/lib/aerospike/client.rb:941:in `execute_command'
from /home/anand/.rvm/gems/ruby-2.1.5/gems/aerospike-1.0.11/lib/aerospike/client.rb:749:in `block (2 levels) in query'

```

The index was created from the Aerospike Monitoring console -

 ![](https://us1.discourse-cdn.com/flex019/uploads/aerospike/original/1X/281e8efc05c5e080843fbff3d87be2c20dcb7617.png)

The same index queries using the Node client works okay. The code that works with the node driver -

```javascript
app.get('/history/:vin', function (req, res) {
  console.log('History for VIN - ' + req.params.vin);
  var vin = req.params.vin;

  var statement = {};
  var filter = aerospike.filter;
  statement.filters = [filter.equal("vin", vin)]; 
  statement.select = ["id", "price", "miles", "scraped_at", "status_date", "is_searchable", "seller_name", "source", "group_id", "grouped_at", "zip", "is_grouped", "touch_count", "is_duplicate"];
  
  var query = client.query('marketcheck', 'listings', statement);
  
  var stream = query.execute();
  var records = [];

  stream.on('data', function(record){
   records.push(record.bins);
  });
  stream.on('error', function(error) {
   console.log("VIN Stream ERROR - " + vin);
   res.json({'status': 2, 'message': error});
  });
  stream.on('end', function() {
   console.log("VIN Stream end - " + vin + " Total records - " + records.length);
   records.sort(function(a,b){return parseInt(b.status_date) - parseInt(a.status_date)});
   res.json({'status': 1, 'data': records})
  });
});

```

---

<div class="post-metadata">

**Author:** ![Jan](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/jan/32/1124_2.png) [@Jan](https://discuss.aerospike.com/u/Jan)\
**Post date:** [January 14, 2016, 10:23am UTC](https://discuss.aerospike.com/t/index-error-with-ruby-client/2390/2 "2016-01-14T10:23:21Z")

</div>

Hi Anand,

This is strange indeed. The code looks correct and I’m not able to reproduce the issue.

Can you check the server logs to see if there is a warning message from the `sindex` submodule when you issue the query from the Ruby client? Try grepping for `WARN (sindex)`. That would give us more insight into why the server might be sending a generic index error.

Cheers, Jan

---

<div class="post-metadata">

**Author:** ![Anand\_Mahajan](https://avatars.discourse-cdn.com/v4/letter/a/ed8c4c/32.png) [@Anand\_Mahajan](https://discuss.aerospike.com/u/Anand_Mahajan)\
**Post date:** [January 14, 2016, 10:56am UTC](https://discuss.aerospike.com/t/index-error-with-ruby-client/2390/3 "2016-01-14T10:56:12Z")

</div>

Got it from the logs -

WARNING (sindex): (secondary\_index.c::2259) Size of the bin name in bin list of sindex query is out of bounds. Size 15

One of the bins from the list is of length 15. Perhaps the error could be better worded to indicate that its the bin name issue from the client query and not a server side index issue as the “Index Error” probably indicates?

Regards, Anand

---

<div class="post-metadata">

**Author:** ![Anand\_Mahajan](https://avatars.discourse-cdn.com/v4/letter/a/ed8c4c/32.png) [@Anand\_Mahajan](https://discuss.aerospike.com/u/Anand_Mahajan)\
**Post date:** [January 14, 2016, 11:10am UTC](https://discuss.aerospike.com/t/index-error-with-ruby-client/2390/4 "2016-01-14T11:10:52Z")

</div>

Edited one of the bins from bins array in the ruby code above - “is\_searchable” to “is\_searchable\_is” - which is 16 char long and that was causing the error.

---

<div class="post-metadata">

**Author:** ![Jan](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/jan/32/1124_2.png) [@Jan](https://discuss.aerospike.com/u/Jan)\
**Post date:** [January 15, 2016, 8:04am UTC](https://discuss.aerospike.com/t/index-error-with-ruby-client/2390/5 "2016-01-15T08:04:46Z")

</div>

Glad you were able to pinpoint the issue after checking the server logs. I agree that the error message returned on the client side is not very helpful. The problem is that the server returns a generic index error. Maybe I’ll just add a message “Check server logs” in this case.

---

<div class="post-metadata">

**Author:** ![Anand\_Mahajan](https://avatars.discourse-cdn.com/v4/letter/a/ed8c4c/32.png) [@Anand\_Mahajan](https://discuss.aerospike.com/u/Anand_Mahajan)\
**Post date:** [January 15, 2016, 1:30pm UTC](https://discuss.aerospike.com/t/index-error-with-ruby-client/2390/6 "2016-01-15T13:30:32Z")

</div>

Yeah. That would help - its difficult to guess that “Index Error” could possibly related to bin name length. Thanks for your help.
