# Scripting using lang-python

**URL:** <https://discuss.elastic.co/t/scripting-using-lang-python/6286>\
**Category:** Elasticsearch\
**Created:** [January 4, 2012, 4:46pm UTC](https://discuss.elastic.co/t/scripting-using-lang-python/6286 "2012-01-04T16:46:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![awopython](https://avatars.discourse-cdn.com/v4/letter/a/f6c823/32.png) [@awopython](https://discuss.elastic.co/u/awopython)\
**Post date:** [January 4, 2012, 4:46pm UTC](https://discuss.elastic.co/t/scripting-using-lang-python/6286/1 "2012-01-04T16:46:41Z")

</div>

We have implemented a custom\_score\_query that needs a more robust  
scoring algorithm that calculates score differently based on  
doc["\_type"]. For these calculations, we need the current date/time.  
We would like to implement a preloaded script in python but have been  
unable to find any samples. Could you point us to some examples?

Additionally, we want to better understand the capabilities of the  
lang-python plugin? Can we import python modules? Can we get the  
current date/time within the script?

We appreciate your assistance.

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [January 5, 2012, 1:46pm UTC](https://discuss.elastic.co/t/scripting-using-lang-python/6286/2 "2012-01-05T13:46:16Z")

</div>

On Wed, Jan 4, 2012 at 6:46 PM, awopython [aoliver865@gmail.com](mailto:aoliver865@gmail.com) wrote:

> We have implemented a custom\_score\_query that needs a more robust  
> scoring algorithm that calculates score differently based on  
> doc["\_type"]. For these calculations, we need the current date/time.  
> We would like to implement a preloaded script in python but have been  
> unable to find any samples. Could you point us to some examples?

You can pass the timestamp as a parameter to the script, or get the current  
timestamp using python (I am not familiar enough with python to tell you  
how to do it).

> Additionally, we want to better understand the capabilities of the  
> lang-python plugin? Can we import python modules? Can we get the  
> current date/time within the script?

The support for python uses jython, so whatever you can do there...

> We appreciate your assistance.

---

<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 6, 2017, 3:43am UTC](https://discuss.elastic.co/t/scripting-using-lang-python/6286/3 "2017-07-06T03:43:45Z")

</div>

Closed on July 6, 2017, 3:43am UTC


