Joining threads when dealing with elasticsearch