Closed
Description
I am unable to post data to machine learning jobs via the MlClient post_data method. There seems to be a problem with getting the data:
Here is a json doc example named file_name.json:
[{"myid": "id1", "client": "client1", "submit_date": 1514764857},{"my_id": "id2", "client": "client_2", "submit_date": 1514764857}]
Here is some example code used to post the data:
from elasticsearch import Elasticsearch
from elasticsearch.client.xpack import MlClient
es = elastic_connection()
es_ml = MlClient(es)
def post_training_data(directory='Training Data', file_name='file_name.json'):
with open(os.path.join(directory, file_name), mode='r') as train_file:
train_data = json.load(train_file)
es_ml.post_data(job_id=job_id, body=train_data)
post_training_data()
Here is the error I am getting when sending json docs:
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "..\train_model.py", line 218, in post_training_data
self.es_ml.post_data(job_id=self.job_id, body=train_data)
File "..\inc_anamoly\lib\site-packages\elasticsearch\client\utils.py", line 76, in _wrapped
return func(*args, params=params, **kwargs)
File "..\inc_anamoly\lib\site-packages\elasticsearch\client\xpack\ml.py", line 81, in post_data
body=self._bulk_body(body))
AttributeError: 'MlClient' object has no attribute '_bulk_body'
Metadata
Metadata
Assignees
Labels
No labels