basho/riak-python-client — Issue #93: search using secondary index fails if key_start == key_end
Author: carlopires
Created: 2011-12-07 15:48:23+00:00
State: open

Just testing 2i so I tryed:

import riak

client = riak.RiakClient(port=8071, transport_class=riak.RiakPbcTransport)

user_bucket = client.bucket('users')
admin_user = user_bucket.new('admin', data={'username': 'admin', 'password': '123'})
admin_user.add_index('username_bin', 'admin')
admin_user.store()

for obj_link in client.index('users', 'username_bin', 'admin').run():
obj = obj_link.get()
print obj.get_data()

# WHY THIS SEARCH CAUSES ERROR?

for obj_link in client.index('users', 'username_bin', 'admin', 'admin').run():
obj = obj_link.get()
print obj.get_data()

Then I get:

carlo@carlo-laptop:/tmp$ python2.7 testriak.py
{u'username': u'admin', u'password': u'123'}
Traceback (most recent call last):
File "testriak.py", line 16, in
for obj_link in client.index('users', 'username_bin', 'admin', 'admin').run():
File "/usr/local/lib/python2.7/site-packages/riak/mapreduce.py", line 230, in run
result = t.mapred(self._inputs, query, timeout)
File "/usr/local/lib/python2.7/site-packages/riak/transports/pbc.py", line 360, in mapred
_handle_response)
File "/usr/local/lib/python2.7/site-packages/riak/transports/pbc.py", line 393, in send_msg_multi
msg_code, resp = self.recv_msg(conn, expect)
File "/usr/local/lib/python2.7/site-packages/riak/transports/pbc.py", line 413, in recv_msg
self.recv_pkt(conn)
File "/usr/local/lib/python2.7/site-packages/riak/transports/pbc.py", line 460, in recv_pkt
len(nmsglen))
riak.RiakError: 'Socket returned short packet length 0 - expected 4'