使用Kafka和Python将数据发送到Elasticsearch时抛出RequestError

时间:2018-12-12 16:30:09

标签: python elasticsearch apache-kafka

我的主题名称是mytopic。我的使用者可以从csv产生JSON资料。我的CSV低于

owner,Rank,Model,mileage,priceincrore,torque
maws,1,Audi,20,2,7000
drav,2,Benz,23,3,8000
ere,3,Ford,12,1,5400

我的python代码在下面

from kafka import KafkaConsumer
import json
from elasticsearch import Elasticsearch
from datetime import datetime
import datetime

es = Elasticsearch([{'host': 'localhost', 'port': 9200}]) 
consumer = KafkaConsumer(
   'mytopic',
    bootstrap_servers=['localhost:9092'],
    auto_offset_reset='latest',
    enable_auto_commit=True)


for val in kafkaconsumer:
    current_values = loads(val.value)
    es.index(index='esindex', doc_type='my_type',id=1, body=current_values)
  

logger.warning('来自服务器的不可解码的原始错误响应:%s',错误)    引发HTTP_EXCEPTIONS.get(status_code,TransportError)(status_code,error_message,additional_info)   RequestError:RequestError(400,“ mapper_parsing_exception”,“解析失败”)

0 个答案:

没有答案