# Access Indexreader object in search context of an elastic search plugin

**URL:** <https://discuss.elastic.co/t/access-indexreader-object-in-search-context-of-an-elastic-search-plugin/137902>\
**Category:** Elasticsearch\
**Created:** [June 29, 2018, 5:17am UTC](https://discuss.elastic.co/t/access-indexreader-object-in-search-context-of-an-elastic-search-plugin/137902 "2018-06-29T05:17:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hardik\_Dobariya](https://avatars.discourse-cdn.com/v4/letter/h/dbc845/32.png) [@Hardik\_Dobariya](https://discuss.elastic.co/u/Hardik_Dobariya)\
**Post date:** [June 29, 2018, 5:17am UTC](https://discuss.elastic.co/t/access-indexreader-object-in-search-context-of-an-elastic-search-plugin/137902/1 "2018-06-29T05:17:28Z")

</div>

I am new to Elasticsearch plugins and finding difficult on how to access Indexreader object in a plugin while performing the searching request of an index. I want something like this.  
A user performs the search request

> Post my\_index/Plugin-Test/\_search

On executing the above, Plugin-Test should be called with access of the Indexreader object.

Please provide me sample code for the same

---

<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:** [June 29, 2018, 2:32pm UTC](https://discuss.elastic.co/t/access-indexreader-object-in-search-context-of-an-elastic-search-plugin/137902/2 "2018-06-29T14:32:21Z")

</div>

You may want to take a look at the `SearchPlugin` interface in Elasticsearch, that you plugin might want to implement.

Note, that you cannot overwrite the above endpoint, you can only extend the query functionality.

If you want to take a look at some example plugins, take a look at [https://github.com/elastic/elasticsearch/tree/6.3/plugins/examples](https://github.com/elastic/elasticsearch/tree/6.3/plugins/examples)

---

<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 27, 2018, 2:32pm UTC](https://discuss.elastic.co/t/access-indexreader-object-in-search-context-of-an-elastic-search-plugin/137902/3 "2018-07-27T14:32:22Z")

</div>

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