The bulk request must be terminated by a newline [\\n]
lopacp opened this issue · 2 comments
Elasticsearch version (bin/elasticsearch --version):
8.12.1
elasticsearch-py version (elasticsearch.__versionstr__):
8.14.0
Description of the problem including expected versus actual behavior:
Bulk index using helpers.bulk/helpers.bulkstream fails with :
raise HTTP_EXCEPTIONS.get(meta.status, ApiError)( elasticsearch.BadRequestError: BadRequestError(400, 'illegal_argument_exception', 'The bulk request must be terminated by a newline [\\n]')
Steps to reproduce:
Run example from tutorial page : https://elasticsearch-py.readthedocs.io/en/v8.14.0/helpers.html#example
pip3.12 freeze
certifi==2024.6.2
elastic-transport==8.13.1
elasticsearch==8.14.0
numpy==2.0.0
pandas==2.2.2
python-dateutil==2.9.0.post0
pytz==2024.1
six==1.16.0
tzdata==2024.1
urllib3==2.2.2
Hello! Thanks for the report. Using the code you linked, I am not able to reproduce. This code executes without errors:
from elasticsearch import Elasticsearch
from elasticsearch.helpers import bulk
client = Elasticsearch(
"https://...es.europe-west9.gcp.elastic-cloud.com",
api_key="...",
)
def gendata():
mywords = ['foo', 'bar', 'baz']
for word in mywords:
yield {
"_index": "mywords",
"word": word,
}
bulk(client, gendata())Are you sure you're not using client.bulk directly instead of the bulk helper?