# Elastica script isn't performing division

**URL:** <https://discuss.elastic.co/t/elastica-script-isnt-performing-division/134175>\
**Category:** Elasticsearch\
**Created:** [June 1, 2018, 8:49am UTC](https://discuss.elastic.co/t/elastica-script-isnt-performing-division/134175 "2018-06-01T08:49:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Islam\_Elshobokshy](https://avatars.discourse-cdn.com/v4/letter/i/77aa72/32.png) [@Islam\_Elshobokshy](https://discuss.elastic.co/u/Islam_Elshobokshy)\
**Post date:** [June 1, 2018, 8:49am UTC](https://discuss.elastic.co/t/elastica-script-isnt-performing-division/134175/1 "2018-06-01T08:49:57Z")

</div>

I've got a script ([Elastica](http://elastica.io)) :

> $agg\_car-\>setScript(" doc['field'].value / doc['field'].size() ");

that isn't performing the division. If I setScript as `doc['field'].value` it gives me 20, if I set it as `doc['field'].size()`it gives me 4. But when I put them both between a division I always get 20. As if the division isn't made and/or he's ignoring the size. I get the same result (20) in the following cases :

> $agg\_car-\>setScript(" doc['field'].value // doc['field'].size() ");  
> $agg\_car-\>setScript(" doc['field'].value \* doc['field'].size() ");  
> $agg\_car-\>setScript(" doc['field'].size() \* doc['field'].value ");

I only get an error in this case :

> $agg\_car-\>setScript(" doc['field'].size() / doc['field'].value ");

---

<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:** [June 29, 2018, 8:49am UTC](https://discuss.elastic.co/t/elastica-script-isnt-performing-division/134175/2 "2018-06-29T08:49:57Z")

</div>

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