# Scripts fields error Elastic 5.1

**URL:** <https://discuss.elastic.co/t/scripts-fields-error-elastic-5-1/74398>\
**Category:** Elasticsearch\
**Created:** [February 8, 2017, 3:53pm UTC](https://discuss.elastic.co/t/scripts-fields-error-elastic-5-1/74398 "2017-02-08T15:53:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mauriciofs](https://avatars.discourse-cdn.com/v4/letter/m/d07c76/32.png) [@mauriciofs](https://discuss.elastic.co/u/mauriciofs)\
**Post date:** [February 8, 2017, 3:53pm UTC](https://discuss.elastic.co/t/scripts-fields-error-elastic-5-1/74398/1 "2017-02-08T15:53:09Z")

</div>

Hello,  
I'm getting the error **No field found for [idling\_points] in mapping with types []** when I'm trying to execute a query with script\_fields

My query:

```auto
curl -X POST -H "Content-Type: application/json" -H "Cache-Control: no-cache" -d '{
	"query": {
		"match_all": {}
	},
    "script_fields": {
	    "total_idling": {
	      "script": {
	        "lang": "painless",
	        "inline": "doc.idling_points.length"
	      }
	    }
	  }
}' "http://127.0.0.1:9200/_search"

```

My mapping template creation is here: [https://gist.github.com/mauriciofs/3cbe65b64acba2b0e199a4e59e0809d8](https://gist.github.com/mauriciofs/3cbe65b64acba2b0e199a4e59e0809d8)

And the document has this structure:

```auto
{
        "_index": "journeys-2016-12",
        "_type": "journeys",
        "_id": "357464034784170-1482391814",
        "_score": 1,
        "_source": {
          "tracker_uid": 824,
          "driver_id": "",
          "start_location": "[Route_4.1_BS 1-93] 200 Jugback Ln, Castlefarm, Swords, Co. Dublin, Ireland",
          "stop_location": "Cloghran, Dublin, Ireland",
          "company_id": 27009,
          "vehicle_id": 1025,
          "start_date_time": "2016-12-22 07:30:14",
          "end_date_time": "2016-12-22 08:10:36",
          "speed_max_kph": 59,
          "journey_time_secs": 2422,
          "created_at": "2016-12-22 08:08:23",
          "stop_point": {
            "lon": -6.3601,
            "lat": 53.41
          },
          "distance_km": 17.78,
          "start_point": {
            "lat": 53.464,
            "lon": -6.22312
          },
          "speed_average_kph": 26,
          "idling_time_secs": 924,
          "journeys_per_hour": [],
          "idling_points": [
            {
              "start": {
                "acquisition_time": 1482391814,
                "location": {
                  "lat": 53.464,
                  "lon": -6.22312
                }
              },
              "end": {
                "acquisition_time": 1482392581,
                "location": {
                  "lat": 53.464,
                  "lon": -6.22312
                }
              }
            },
            {
              "start": {
                "acquisition_time": 1482392783,
                "location": {
                  "lat": 53.46686,
                  "lon": -6.23842
                }
              },
              "end": {
                "acquisition_time": 1482392790,
                "location": {
                  "lat": 53.46692,
                  "lon": -6.23873
                }
              }
            },
            {
              "start": {
                "acquisition_time": 1482392858,
                "location": {
                  "lat": 53.45954,
                  "lon": -6.24207
                }
              },
              "end": {
                "acquisition_time": 1482392889,
                "location": {
                  "lat": 53.45943,
                  "lon": -6.2423
                }
              }
            },
            {
              "start": {
                "acquisition_time": 1482393584,
                "location": {
                  "lat": 53.42337,
                  "lon": -6.32573
                }
              },
              "end": {
                "acquisition_time": 1482393703,
                "location": {
                  "lat": 53.42343,
                  "lon": -6.32904
                }
              }
            }
          ],
          "tracker_id": "357464034784170",
          "vehicle_details": {
            "registration": "08D69271",
            "description": "WI Gerry Maguire",
            "label": "WI.Gerry Maguire",
            "label_color": "blue_label",
            "icon": "caddy",
            "model": "Caddy 2.0 D 51KW DSD 6DR",
            "fuel_type": "diesel",
            "type": "van",
            "make": "Volkswagen "
          },
          "start_date": "2016-12-22",
          "start_time": "07:30:14",
          "end_date": "2016-12-22",
          "end_time": "08:10:36",
          "start_location_group": "null",
          "stop_location_group": "",
          "start_location_name": "Route_4.1_BS 1-93",
          "stop_location_name": "",
          "driver_details": {}
        }
      }

```

idling\_points it's an array of objects which is a nested type, am I doing the query wrong?  
Elastic search 5.1 Lucene version 6.4.0

---

<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:** [March 8, 2017, 3:53pm UTC](https://discuss.elastic.co/t/scripts-fields-error-elastic-5-1/74398/2 "2017-03-08T15:53:24Z")

</div>

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