# Percolator with scripting

**URL:** https://discuss.elastic.co/t/percolator-with-scripting/13049
**Category:** Elasticsearch
**Created:** [August 2, 2013, 9:25pm UTC](https://discuss.elastic.co/t/percolator-with-scripting/13049 "2013-08-02T21:25:08Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Yan\_Wang](https://avatars.discourse-cdn.com/v4/letter/y/b5ac83/32.png) [@Yan\_Wang](https://discuss.elastic.co/u/Yan_Wang)
#### Post date: [August 2, 2013, 9:25pm UTC](https://discuss.elastic.co/t/percolator-with-scripting/13049/1 "2013-08-02T21:25:08Z")

</div>

Hi! Seems the script in percolator does not work.

Here is my test:

---------------- mapping --------------------------  
[http://localhost:9200/test](http://localhost:9200/test)  
{  
"mappings": {  
"event": {  
"properties": {  
"integer": {  
"type": "integer"  
}  
}  
}  
},  
"settings": {  
"index": {  
"number\_of\_shards": "1",  
"number\_of\_replicas": 0  
}  
}  
}

-------------- percolator ----------------------------  
[http://localhost:9200/\_percolator/test/sub-1](http://localhost:9200/_percolator/test/sub-1)  
{  
"query": {  
"match": {  
"integer": 2  
}  
},  
"script\_fields": {  
"integer": {  
"script": "doc['integer'].value \* 2"  
}  
}  
}

------------ percolate---------------------------  
[http://localhost:9200/test/event/\_percolate](http://localhost:9200/test/event/_percolate)  
{"doc":{"integer":"1"}}

I hope the script will do the work and make the doc like  
{"doc":{"integer":"2"}} so that I can get matches. But seems it does not.  
Any idea?

Thanks a lot!

--  
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: ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)
#### Post date: [August 5, 2013, 7:02am UTC](https://discuss.elastic.co/t/percolator-with-scripting/13049/2 "2013-08-05T07:02:33Z")

</div>

Hey,

the percolator mechanism allows you to register a query, which is supposed  
to match, but not to execute a script against it (as the script\_fields  
feature is not part of the query phase). Best would be if you do that kind  
of calculation upfront and then percolate...

--Alex

On Fri, Aug 2, 2013 at 11:25 PM, Yan Wang [ywang4362@gmail.com](mailto:ywang4362@gmail.com) wrote:

> Hi! Seems the script in percolator does not work.
> 
> Here is my test:
> 
> ---------------- mapping --------------------------  
> [http://localhost:9200/test](http://localhost:9200/test)  
> {  
> "mappings": {  
> "event": {  
> "properties": {  
> "integer": {  
> "type": "integer"  
> }  
> }  
> }  
> },  
> "settings": {  
> "index": {  
> "number\_of\_shards": "1",  
> "number\_of\_replicas": 0  
> }  
> }  
> }
> 
> -------------- percolator ----------------------------  
> [http://localhost:9200/\_percolator/test/sub-1](http://localhost:9200/_percolator/test/sub-1)  
> {  
> "query": {  
> "match": {  
> "integer": 2  
> }  
> },  
> "script\_fields": {  
> "integer": {  
> "script": "doc['integer'].value \* 2"  
> }  
> }  
> }
> 
> ------------ percolate---------------------------  
> [http://localhost:9200/test/event/\_percolate](http://localhost:9200/test/event/_percolate)  
> {"doc":{"integer":"1"}}
> 
> I hope the script will do the work and make the doc like  
> {"doc":{"integer":"2"}} so that I can get matches. But seems it does not.  
> Any idea?
> 
> Thanks a lot!
> 
> --  
> 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:23am UTC](https://discuss.elastic.co/t/percolator-with-scripting/13049/3 "2017-07-06T02:23:01Z")

</div>


