# Cannot convert type of nested field

**URL:** https://discuss.elastic.co/t/cannot-convert-type-of-nested-field/115768
**Category:** Logstash
**Created:** [January 16, 2018, 6:03pm UTC](https://discuss.elastic.co/t/cannot-convert-type-of-nested-field/115768 "2018-01-16T18:03:06Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![leafarlins](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leafarlins/32/69600_2.png) [@leafarlins](https://discuss.elastic.co/u/leafarlins)
#### Post date: [January 16, 2018, 6:03pm UTC](https://discuss.elastic.co/t/cannot-convert-type-of-nested-field/115768/1 "2018-01-16T18:03:07Z")

</div>

Hi. I am trying to convert a field read by a json filter in logstash. I am used to convert fields from other sources, but with this nested field from a json log file, I cannot convert a quoted number string to a integer.

This is an example line of log:  
`{"timestamp":"2018-01-16T15:31:40.82","mensagem":"Requisição finalizada com sucesso.","source_host":"vm513-0.rede.tst","thread_id":297,"thread_name":"default task-57","logger_name":"br.jus.csjt.pje.core.infra.seguranca.PjeContextoResponseFilter","level":"INFO","class":"br.jus.csjt.pje.core.infra.seguranca.PjeContextoResponseFilter","method":"finalizarContextoRequisicao","contexto":{"requisicao.idPerfil":"30000","requisicao.siglaSistema":"PJE","requisicao.api.tipo":"GET","requisicao.tipoToken":"USUARIO","requisicao.timestamp.inicio":"2018-01-16T17:31:40.611Z","requisicao.papel":"MAGISTRADO","requisicao.api.operacao":"br.jus.csjt.pje.service.api.escaninho.EscaninhoDocumentoApi.buscarDocumentosInternos","requisicao.duracao.milissegundos":"209","requisicao.instancia":"1"}}`

In the beggining of my logstash code, I apply the json filter.

```
json {
  source => "message"
}

```

All fields are created in my new index in elasticsearch. But I would like to convert the field requisicao.duracao.milissegundos to integer. I've tried it all (examples bellow).

```
mutate {
  convert => ["[contexto][requisicao][duracao][milissegundos]", "integer" ]    
  convert => { "[contexto][requisicao][duracao][milissegundos]" => "integer" }
  convert => ["contexto.requisicao.duracao.milissegundos", "integer"]
}

```

I've tried different syntaxes, removing old indexes and re-creating it to create new mappings in elasticsearch, but I could not read this field. It always appears as text. Any idea? I am using logstash and elasticsearch 6.x.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [February 13, 2018, 6:03pm UTC](https://discuss.elastic.co/t/cannot-convert-type-of-nested-field/115768/2 "2018-02-13T18:03:48Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
