omc / searchyll

GNU General Public License v3.0
48 stars 15 forks source link

Better compliance with Elasticsearch API #42

Closed alranel closed 5 years ago

alranel commented 5 years ago

Documentation for Elasticsearch Bulk API says that requests should carry the Content-Type: application/x-ndjson header.

I also observed that Elasticsearch was rejecting some of my updates with a The bulk request must be terminated by a newline error, which was caused by Searchyll not sending data in binary mode. Adding .force_encoding('ascii-8bit') solved the issue for me.

I also noticed that Searchyll was sending empty requests to the Bulk API, which caused an error by Elasticsearch. This PR prevents such empty requests.