Error while updating a document in ElasticSearch using python es.update()

我的未来我决定 提交于 2020-02-08 09:11:09

问题


I am trying to update a document in elasticsearch using the default python interface for Elasticsearch using the below command.

res = es.update(index='its', doc_type='vents', id=txid, body={"doc":{"f_vent" :{"b_vent":rx_buffer}}})

The updated document is shown below.

{
  "_index": "its",
  "_type": "vents",
  "_id": "4752956038",
  "_score": null,
  "_source": {
    "ResponseTime": 0,
    "Session": "None",
    "Severity": "warn",
    "StatusCode": 0,
    "Subject": "Reporting Page Load Time",
    "Time": "Fri Jun 05 2015 12:23:46 GMT+1200 (NZST)",
    "Timestamp": "1433463826535",
    "TransactionId": "4752956038",
    "msgType": "0",
    "tid": "1",
    "f_vent": {
      "b_vent": "{\"ActiveTransactions\": 6, \"AppName\": \"undefined\", \"TransactionId\": \"4752956038\",  \"UserInfo\": \"Unknown\"}"
    }
  },
  "fields": {
    "_timestamp": 1433818222372
  },
  "sort": [
    1433818222372
  ]
}

I copied this from Kibana4 discover tab by expanding the document.The 'transaction Id' inside b_vent has to be accessed as f_vent.b_vent.TransactionId. I suspect this is putting some restricions on me plotting a graph on transaction Id. I tried using

res = es.update(index='its', doc_type='vents', id=txid, body={"doc":{"b_vent":rx_buffer}})

so that I could use b_vent.TransactionId but I am getting the following error when calling es.update().

 raise HTTP_EXCEPTIONS.get(status_code, TransportError)(status_code, error_message, additional_info)
RequestError: TransportError(400, u'MapperParsingException[object mapping for [events] tried to parse field [be_event] as object, but got EOF, has a concrete value been provided to it?]')

What am I doing wrong? How can I fix this problem?

This is the almost full strucuture of b_vent.

"{
    \"ActiveTr\": 6,
    \"ErrorM\": \"None\",
    \"HError\": \"false\",
    \"HMPct\": 62,
    \"NHMPct\": 57,
    \"Parameter\": \"1433195852706\",
    \"ParameterD\": \"false\",
    \"ProcessCPU\": 1,
    \"Proxies\": \"None\",
    \"RStatusCode\": \"34500\",
    \"Severity\": \"info\",
    \"ThrWtTi\": -1,
    \"ThrWai\": 16,
    \"Timestamp\": \"TueJun0209: 58: 16NZST2015\",
    \"TxId\": \"316029416\",
    \"UserInfo\": \"Unknown\"
}"

It does seem to have some strange escape sequences. I am not sure why they are there. But json.loads() does seem to parse the file. I don't know how to fix this issue?

来源:https://stackoverflow.com/questions/30722703/error-while-updating-a-document-in-elasticsearch-using-python-es-update

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!