Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Elasticsearch shows data as buffer type in Kibana

I am trying to index one json to elastic search.

It seems to be working fine as it is not giving any error.

I have indexed document as below.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

await client.index({
            id: fieldId.toString(),
            index: 'project_documents_textfielddata',
            body: {
              FieldId: fieldId,
              DocumentId: documentId,
              Value: fieldData.fieldHTMLText,
            },
            routing: projectId.toString(),
          });

But in elasticsearch kibana it is showing as buffer type as below (I have truncated buffer as it was very long).

{
  "_index": "documenttextfile.files",
  "_id": "6252ab411deaba21fd877c26",
  "_version": 1,
  "_score": 1,
  "_routing": "62505a765ff176cd491f1d1e",
  "_source": {
    "id": "6252ab411deaba21fd877c26",
    "Content": {
      "type": "Buffer",
      "data": [
        10,
     // Some extra large binary content removed for convenient
      48,
      56,
      50,
    ],
    "id": [
      "6252ab411deaba21fd877c26"
    ],
    "Content.type.keyword": [
      "Buffer"
    ]
  }
}

So how can I see my data as is (i.e. in json format) in Kibana. I’ve seen many tutorials on Kibana, they are able to see data in plain text instead of buffer.

Or am I doing anything wrong while indexing? I am basically trying to see the data the way we can see in mongodb compass.

>Solution :

Your fieldData.fieldHTMLTextfield is probably of type Buffer and you simply need to call fieldData.fieldHTMLText.toString()on it in order to transform the buffer to a string.

PS: the problem has nothing to do with Kibana which shows you exactly what you’re sending to Elasticsearch, i.e. a Buffer. So the problem is more related to your understand of Node.js data structures (i.e. Buffer vs string) 😉

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading