# How Script Filters are implemented internally

**URL:** <https://discuss.elastic.co/t/how-script-filters-are-implemented-internally/11782>\
**Category:** Elasticsearch\
**Created:** [May 2, 2013, 4:22pm UTC](https://discuss.elastic.co/t/how-script-filters-are-implemented-internally/11782 "2013-05-02T16:22:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Txus](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/txus/32/2353_2.png) [@Txus](https://discuss.elastic.co/u/Txus)\
**Post date:** [May 2, 2013, 4:22pm UTC](https://discuss.elastic.co/t/how-script-filters-are-implemented-internally/11782/1 "2013-05-02T16:22:47Z")

</div>

Hi,

I'm working on a native ElasticSearch plugin (using the Java API). I was  
logging stuff to stdout to debug some things, and I noticed two things:

- The script was running non-deterministically on the various documents,  
which makes sense, and
- The script was running more than once _per document_. Which seems like  
a waste?

I've been browsing the source code trying to find where's this mapping  
[Documents] =\> [Filtered documents], with no luck. Does anyone know how the  
script filters know exactly, so that maybe we could find out why scripts  
are running more than once per document?

Cheers!

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [May 2, 2013, 7:18pm UTC](https://discuss.elastic.co/t/how-script-filters-are-implemented-internally/11782/2 "2013-05-02T19:18:22Z")

</div>

Could you provide some sample code which demonstrates this?

ta

Clint

On Thu, May 2, 2013 at 6:22 PM, Txus [josep.m.bach@gmail.com](mailto:josep.m.bach@gmail.com) wrote:

> Hi,
> 
> I'm working on a native Elasticsearch plugin (using the Java API). I was  
> logging stuff to stdout to debug some things, and I noticed two things:
> 
> - The script was running non-deterministically on the various  
> documents, which makes sense, and
> - The script was running more than once _per document_. Which seems  
> like a waste?
> 
> I've been browsing the source code trying to find where's this mapping  
> [Documents] =\> [Filtered documents], with no luck. Does anyone know how the  
> script filters know exactly, so that maybe we could find out why scripts  
> are running more than once per document?
> 
> Cheers!
> 
> --  
> 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).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:38am UTC](https://discuss.elastic.co/t/how-script-filters-are-implemented-internally/11782/3 "2017-07-06T02:38:35Z")

</div>


