# Indexed document has an unknown field

**URL:** <https://discuss.elastic.co/t/indexed-document-has-an-unknown-field/223356>\
**Category:** Kibana\
**Created:** [March 12, 2020, 2:43pm UTC](https://discuss.elastic.co/t/indexed-document-has-an-unknown-field/223356 "2020-03-12T14:43:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ethranes](https://avatars.discourse-cdn.com/v4/letter/e/e56c9b/32.png) [@ethranes](https://discuss.elastic.co/u/ethranes)\
**Post date:** [March 12, 2020, 2:43pm UTC](https://discuss.elastic.co/t/indexed-document-has-an-unknown-field/223356/1 "2020-03-12T14:43:00Z")

</div>

Hi, I've made an index using dynamic mapping. The document that I've used when creating it looks like this;

```
{
  "graph":{
    "id":601,
    "name":"Graph",
    "labels":[
      {
        "user":"*B",
        "id":16,
        "colour":"157AFF",
        "value":9
      },
      {
        "user":"A",
        "id":534,
        "colour":"EEAF1B",
        "value":0
      },
      {
        "user":"J",
        "id":1954326,
        "colour":"C15CB9",
        "value":9
      }
    ]
  }
}

```

When I check the document in the discover it has all of the label entries under graph.labels and it's an unknown field.

 ![elasticgraphlabel](https://us1.discourse-cdn.com/elastic/original/3X/5/6/56cef08ffd7f202b643a6ed9c9bc5150592360fa.png)

I want to make sure that all of the values inside the label, e.g. user, value etc. Are searchable correctly and that I can use them for creating visualisations.

How can I stop the graph.label from being an unknown type and make sure that I can use all my data for visualisations.

Thanks.

---

<div class="post-metadata">

**Author:** ![Marius\_Dragomir](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marius_dragomir/32/42087_2.png) [@Marius\_Dragomir](https://discuss.elastic.co/u/Marius_Dragomir)\
**Post date:** [March 12, 2020, 5:10pm UTC](https://discuss.elastic.co/t/indexed-document-has-an-unknown-field/223356/2 "2020-03-12T17:10:30Z")

</div>

You'll need to define them as fields in the ingest. Otherwise, if they're not analyzable, Kibana cannot create an aggregation on it.

---

<div class="post-metadata">

**Author:** ![ethranes](https://avatars.discourse-cdn.com/v4/letter/e/e56c9b/32.png) [@ethranes](https://discuss.elastic.co/u/ethranes)\
**Post date:** [March 13, 2020, 1:35pm UTC](https://discuss.elastic.co/t/indexed-document-has-an-unknown-field/223356/3 "2020-03-13T13:35:48Z")

</div>

I've created the mapping myself instead of using the dynamic mapping, but am still having some trouble with the labels being recognised in the document. My mapping looks like;

```
  "mappings" : {
"properties" : {
  "graph" : {
    "properties" : {
      "active" : {
        "type" : "boolean"
      },
      "createdAt" : {
        "type" : "date"
      },
      "createdBy" : {
        "type" : "keyword"
      },
      "description" : {
        "type" : "text",
        "fields" : {
          "keyword" : {
            "type" : "keyword",
            "ignore_above" : 256
          }
        }
      },
      "id" : {
        "type" : "keyword"
      },
      "labels" : {
        "type" : "nested",
        "properties" : {
          "colour" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "id" : {
            "type" : "keyword"
          },
          "user" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "value" : {
            "type" : "long"
          }
        }
      },
      "modifiedAt" : {
        "type" : "date"
      },
      "modifiedBy" : {
        "type" : "keyword"
      },
      "name" : {
        "type" : "text",
        "fields" : {
          "keyword" : {
            "type" : "keyword",
            "ignore_above" : 256
          }
        }
      },
      "searchableId" : {
        "type" : "keyword"
      },
      "version" : {
        "type" : "keyword"
      }
    }
  }
}

```

}

As you can see I've tried setting the lable type to nested because there will be an array of objects in there.

---

<div class="post-metadata">

**Author:** ![Marius\_Dragomir](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marius_dragomir/32/42087_2.png) [@Marius\_Dragomir](https://discuss.elastic.co/u/Marius_Dragomir)\
**Post date:** [March 13, 2020, 2:37pm UTC](https://discuss.elastic.co/t/indexed-document-has-an-unknown-field/223356/4 "2020-03-13T14:37:22Z")

</div>

Kibana doesn't do aggregations on nested documents. We recommend denormalizing your data in situations like this.

---

<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:** [April 10, 2020, 2:37pm UTC](https://discuss.elastic.co/t/indexed-document-has-an-unknown-field/223356/5 "2020-04-10T14:37:32Z")

</div>

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