# Elasticsearch plugin develop

**URL:** <https://discuss.elastic.co/t/elasticsearch-plugin-develop/187346>\
**Category:** Elasticsearch\
**Created:** [June 25, 2019, 1:38pm UTC](https://discuss.elastic.co/t/elasticsearch-plugin-develop/187346 "2019-06-25T13:38:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![shiwenhao](https://avatars.discourse-cdn.com/v4/letter/s/47e85d/32.png) [@shiwenhao](https://discuss.elastic.co/u/shiwenhao)\
**Post date:** [June 25, 2019, 1:38pm UTC](https://discuss.elastic.co/t/elasticsearch-plugin-develop/187346/1 "2019-06-25T13:38:19Z")

</div>

I want to develop es plugin like the official website example ：[https://github.com/elastic/elasticsearch/blob/master/plugins/examples/script-expert-scoring/src/main/java/org/elasticsearch/example/expertscript/ExpertScriptPlugin.java](https://github.com/elastic/elasticsearch/blob/master/plugins/examples/script-expert-scoring/src/main/java/org/elasticsearch/example/expertscript/ExpertScriptPlugin.java)  
But I have multiple pairs of field and term，how do I deal with the function “ setDocument ”?

Thank you for your reply!

---

<div class="post-metadata">

**Author:** ![rjernst](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rjernst/32/6363_2.png) [@rjernst](https://discuss.elastic.co/u/rjernst)\
**Post date:** [July 1, 2019, 6:16am UTC](https://discuss.elastic.co/t/elasticsearch-plugin-develop/187346/2 "2019-07-01T06:16:55Z")

</div>

For multiple terms/fields, you'll need to load a PostingsEnum for each term. See line 109 in the example you linked. You then need to call setDocument on all of your postings inside `ScriptScore.setDocument` on line 126. This will ensure your postings enums are ready to read inside `ScriptScore.execute`.

---

<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 29, 2019, 6:16am UTC](https://discuss.elastic.co/t/elasticsearch-plugin-develop/187346/3 "2019-07-29T06:16:58Z")

</div>

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