Adjusted for elasticsearch 1.0.0.