# ExpressionScriptCompilationException\[Field \[\<field name\>\] used in expression does not exist in mappings\];

**URL:** <https://discuss.elastic.co/t/expressionscriptcompilationexception-field-field-name-used-in-expression-does-not-exist-in-mappings/22560>\
**Category:** Elasticsearch\
**Created:** [March 6, 2015, 4:27pm UTC](https://discuss.elastic.co/t/expressionscriptcompilationexception-field-field-name-used-in-expression-does-not-exist-in-mappings/22560 "2015-03-06T16:27:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![AlexBV](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alexbv/32/44813_2.png) [@AlexBV](https://discuss.elastic.co/u/AlexBV)\
**Post date:** [March 6, 2015, 4:27pm UTC](https://discuss.elastic.co/t/expressionscriptcompilationexception-field-field-name-used-in-expression-does-not-exist-in-mappings/22560/1 "2015-03-06T16:27:48Z")

</div>

Hi there,  
We're just getting started with ELK and are using:  
Elasticsearch 1.4.4  
Kibana 4.0  
on  
Ubuntu 14.04

We needed to create a scripted field to calculate the ratio between two  
numeric fields. These fields are not on all events and only started  
appearing at all a day ago (so older indexes don't have it at all).  
name: ads\_per\_page  
script: doc['ads\_found'].value / max(1, doc['pages\_parsed'].value)

It seemed to be working great at first but now Kibana has been resurfacing  
these elasticsearch errors constantly and I can't seem to find any  
information about it online (too new?).  
This repeats for every shard as far as I can tell (there are about 2 weeks  
of indexes there. Any suggestions would be appreciated.  
Shard Failures

The following shard failures ocurred:

- _Index:_ logstash-2015.02.21 _Shard:_ 0 _Reason:_ SearchParseException[[logstash-2015.02.21][0]:  
query[ConstantScore(BooleanFilter(+cache(@timestamp:[1425571563220 TO  
1425657963220])))],from[-1],size[500],sort[\<custom:"@timestamp":  
org.elasticsearch.index.fielddata.fieldcomparator.LongValuesComparatorSource@4c1942d3\>!]:  
Parse Failure [Failed to parse source  
[{"size":500,"sort":{"@timestamp":"desc"},"query":{"filtered":{"query":{"query\_string":{"analyze\_wildcard":true,"query":"_"}},"filter":{"bool":{"must":[{"range":{"@timestamp":{"gte":1425571563220,"lte":1425657963220}}}],"must\_not":[]}}}},"highlight":{"pre\_tags":["@kibana-highlighted-field@"],"post\_tags":["@/kibana-highlighted-field@"],"fields":{"_":{}}},"aggs":{"2":{"date\_histogram":{"field":"@timestamp","interval":"30m","pre\_zone":"-08:00","pre\_zone\_adjust\_large\_interval":true,"min\_doc\_count":0,"extended\_bounds":{"min":1425571563220,"max":1425657963220}}}},"fields":["\*","\_source"],"script\_fields":{"ads\_per\_page":{"script":"doc['ads\_found'].value  
/ max(1,  
doc['pages\_parsed'].value)","lang":"expression"}},"fielddata\_fields":["@timestamp"]}]]];  
nested: ExpressionScriptCompilationException[Field [ads\_found] used in  
expression does not exist in mappings];

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/971bfbf2-6210-473b-9098-6262ed302846%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/971bfbf2-6210-473b-9098-6262ed302846%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![AlexBV](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alexbv/32/44813_2.png) [@AlexBV](https://discuss.elastic.co/u/AlexBV)\
**Post date:** [May 18, 2015, 10:27pm UTC](https://discuss.elastic.co/t/expressionscriptcompilationexception-field-field-name-used-in-expression-does-not-exist-in-mappings/22560/2 "2015-05-18T22:27:38Z")

</div>

It looks like the same question (but with more context/information)  
here: [http://stackoverflow.com/questions/28986964/expressions-with-dynamicly-generated-schemas-throw-exceptions-when-some-indices](http://stackoverflow.com/questions/28986964/expressions-with-dynamicly-generated-schemas-throw-exceptions-when-some-indices)  
but doesn't have any answers yet either.

Does anyone here happen to know what the best practice way of addressing  
these indices without the mapping in question? I'd really hate to have to  
go through and hand update them all to have the mapping ☹

On Friday, March 6, 2015 at 8:27:48 AM UTC-8, Alex Schokking wrote:

> Hi there,  
> We're just getting started with ELK and are using:  
> Elasticsearch 1.4.4  
> Kibana 4.0  
> on  
> Ubuntu 14.04
> 
> We needed to create a scripted field to calculate the ratio between two  
> numeric fields. These fields are not on all events and only started  
> appearing at all a day ago (so older indexes don't have it at all).  
> name: ads\_per\_page  
> script: doc['ads\_found'].value / max(1, doc['pages\_parsed'].value)
> 
> It seemed to be working great at first but now Kibana has been resurfacing  
> these elasticsearch errors constantly and I can't seem to find any  
> information about it online (too new?).  
> This repeats for every shard as far as I can tell (there are about 2 weeks  
> of indexes there. Any suggestions would be appreciated.  
> Shard Failures
> 
> The following shard failures ocurred:
> 
> - _Index:_ logstash-2015.02.21 _Shard:_ 0 _Reason:_ SearchParseException[[logstash-2015.02.21][0]:  
> query[ConstantScore(BooleanFilter(+cache(@timestamp:[1425571563220 TO  
> 1425657963220])))],from[-1],size[500],sort[\<custom:"@timestamp":  
> org.elasticsearch.index.fielddata.fieldcomparator.LongValuesComparatorSource@4c1942d3\>!]:  
> Parse Failure [Failed to parse source  
> [{"size":500,"sort":{"@timestamp":"desc"},"query":{"filtered":{"query":{"query\_string":{"analyze\_wildcard":true,"query":"_"}},"filter":{"bool":{"must":[{"range":{"@timestamp":{"gte":1425571563220,"lte":1425657963220}}}],"must\_not":[]}}}},"highlight":{"pre\_tags":["@kibana-highlighted-field@"],"post\_tags":["@/kibana-highlighted-field@"],"fields":{"_":{}}},"aggs":{"2":{"date\_histogram":{"field":"@timestamp","interval":"30m","pre\_zone":"-08:00","pre\_zone\_adjust\_large\_interval":true,"min\_doc\_count":0,"extended\_bounds":{"min":1425571563220,"max":1425657963220}}}},"fields":["\*","\_source"],"script\_fields":{"ads\_per\_page":{"script":"doc['ads\_found'].value  
> / max(1,  
> doc['pages\_parsed'].value)","lang":"expression"}},"fielddata\_fields":["@timestamp"]}]]];  
> nested: ExpressionScriptCompilationException[Field [ads\_found] used in  
> expression does not exist in mappings];

## -- Please update your bookmarks! We have moved to [https://discuss.elastic.co/](https://discuss.elastic.co/)

You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/db5d1ac5-0961-4274-b329-00832834340e%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/db5d1ac5-0961-4274-b329-00832834340e%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![memelet](https://avatars.discourse-cdn.com/v4/letter/m/6bbea6/32.png) [@memelet](https://discuss.elastic.co/u/memelet)\
**Post date:** [June 19, 2016, 7:25am UTC](https://discuss.elastic.co/t/expressionscriptcompilationexception-field-field-name-used-in-expression-does-not-exist-in-mappings/22560/3 "2016-06-19T07:25:11Z")

</div>

We just started seeing this today. No idea why nor how to fix it. Kibana does not work at all with logstash-\* indices now.

---

<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:** [July 5, 2017, 10:42pm UTC](https://discuss.elastic.co/t/expressionscriptcompilationexception-field-field-name-used-in-expression-does-not-exist-in-mappings/22560/4 "2017-07-05T22:42:32Z")

</div>


