What does 'fields' refer to in Kibana->Discover->JSON view?

When I analyze my indices in Discover Tab and click on a doc, and view it in JSON view:


I can see a property called fields. It lists all fields in the doc.
Does it have any relationship to index as in:

But I only indexed following fields.

{
  "mappings": {
    "dynamic": "false",
    "properties": {
      "courseId": {
        "type": "keyword"
      },
      "createdAt": {
        "type": "date"
      },
      "idTokenSub": {
        "type": "keyword"
      }
    }
  }
}

Hi @ACoder,

Discover is using fields option when requesting data from Elasticsearch instead of searching from _source. More info on that API in Retrieve selected fields from a search | Elasticsearch Guide [8.15] | Elastic

Do you have these fields in _source object in the JSON view?

What index pattern is configured for the current Data View? It could be that more than one index is targeted during the Discover search request hence more fields are requested.

Yes


There are some fields starting with "lesson.*", but doesn't appear in mappings, they do exist in _source in JSON view.

Following is what I got when using the API directly in Dev Tools/Console:

POST course-api-study-records/_search
{
  "query": {
    "match_all": {}
  },
  "fields": [
    "*"
  ], 
  "_source": false
}

In Discover requests we also pass include_unmapped. Can you try it in DevTools?

"fields": [
    {
      "field": "*",
      "include_unmapped": true
    }
  ]
1 Like