Ruby-Tire wait for indexes to get created

93 views Asked by At

Using Tire I need to fill indexes in the test cases after I create some records, which I do like this.

['London', 'Mumbai', 'New York'].each { |name| Place.create(name: name) }
t = Tire.index('places')
t.import(Place.all.entries)

How do I wait for the index to be created before proceeding?

1

There are 1 answers

0
Mike S On BEST ANSWER

Call t.refresh directly after you call import. This will ensure that Tire is in sync with elasticsearch.