Description
I'm having problems with Riak and Python client while trying to delete and create a search index after a schema update. Our system check for changes in an XML file with the Solr schema, when the file changes, we refresh the index (update schema, delete index, create index and store all bucket data in the index again).
Roughly, what we are doing is the following:
import riak
c = riak.RiakClient(nodes=[{'host': '127.0.0.1', 'pb_port': 8087}],
protocol='pbc')
schema_data = <xml>
c.bucket('my_bucket').clear_properties()
c.delete_search_index('my_index')
c.create_search_schema('my_schema', schema_data)
c.create_search_index('my_index', 'my_schema')
c.bucket('my_bucket').set_property('search_index', 'my_index')
print c.bucket('my_bucket').search('*:*', index='my_index')
Having 5 records in my_bucket
(and in my_index
), after executing all these sentences, the search
method is still returning the same data as before, I was expecting the Solr's my_index
index to be empty (since I'm not re-indexing the bucket data in my_index
with this code). Also, I cannot see my changes in the Solr schema browser.
But then, after some trial and error, I've noticed the following. If I execute this script:
import riak
c = riak.RiakClient(nodes=[{'host': '127.0.0.1', 'pb_port': 8087}],
protocol='pbc')
c.bucket('my_bucket').clear_properties()
c.delete_search_index('my_index')
And then, in another Python instance, I execute this script:
import riak
c = riak.RiakClient(nodes=[{'host': '127.0.0.1', 'pb_port': 8087}],
protocol='pbc')
schema_data = <xml>
c.create_search_schema('my_schema', schema_data)
c.create_search_index('my_index', 'my_schema')
c.bucket('my_bucket').set_property('search_index', 'my_index')
print c.bucket('my_bucket').search('*:*', index='my_index')
Namely, if I delete the index and create it again separately, everything works fine. my_index
has no data anymore and Solr schema browser shows me the updated schema. Also, I've noticed that create_search_index
has taken a lot more of time to execute (in the first script, everything was executed instantly).
Am I doing something wrong or is this a bug?