# Accessing IndexReader in Plugin

**URL:** <https://discuss.elastic.co/t/accessing-indexreader-in-plugin/6734>\
**Category:** Elasticsearch\
**Created:** [February 16, 2012, 8:50pm UTC](https://discuss.elastic.co/t/accessing-indexreader-in-plugin/6734 "2012-02-16T20:50:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hannescarl](https://avatars.discourse-cdn.com/v4/letter/h/a87d85/32.png) [@hannescarl](https://discuss.elastic.co/u/hannescarl)\
**Post date:** [February 16, 2012, 8:50pm UTC](https://discuss.elastic.co/t/accessing-indexreader-in-plugin/6734/1 "2012-02-16T20:50:43Z")

</div>

Hello,

is it possible to access the IndexReader from the underlying Lucene  
Index inside a plugin?  
I would like to create an ElasticSearch plugin which accesses a  
document directly via the IndexReader.

Code example highly appreciated 😉

Thanks

Hannes

---

<div class="post-metadata">

**Author:** ![Alberto\_Paro\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alberto_paro_2/32/1137_2.png) [@Alberto\_Paro\_2](https://discuss.elastic.co/u/Alberto_Paro_2)\
**Post date:** [February 16, 2012, 10:29pm UTC](https://discuss.elastic.co/t/accessing-indexreader-in-plugin/6734/2 "2012-02-16T22:29:42Z")

</div>

IndexReader cannot be accessed from a plugin because it's a private member of RobinEngine. You need to add some code in the elasticsearch code:

1. a function in RobinEngine to do your job
2. a new action with request, response, transport, ... and add this to the client.

Hi,  
Alberto

Inviato da iPhone

Il giorno 16/feb/2012, alle ore 21:50, hannescarl [hannescarl@googlemail.com](mailto:hannescarl@googlemail.com) ha scritto:

> Hello,
> 
> is it possible to access the IndexReader from the underlying Lucene  
> Index inside a plugin?  
> I would like to create an Elasticsearch plugin which accesses a  
> document directly via the IndexReader.
> 
> Code example highly appreciated 😉
> 
> Thanks
> 
> Hannes

---

<div class="post-metadata">

**Author:** ![hannescarl](https://avatars.discourse-cdn.com/v4/letter/h/a87d85/32.png) [@hannescarl](https://discuss.elastic.co/u/hannescarl)\
**Post date:** [February 17, 2012, 6:02am UTC](https://discuss.elastic.co/t/accessing-indexreader-in-plugin/6734/3 "2012-02-17T06:02:21Z")

</div>

Thanks for that Answer, RobinEngine was exactly I was looking for!

I need to iterate through all documents in an Index, compute  
something 😉 and send the response to the client.

Do you think that would work in a distributed scenario?

- Send request
- Iterate through documents in each node
- merge request
- Send response

Kind Regards

Hannes

On 16 Feb., 23:29, Alberto Paro [alberto.p...@gmail.com](mailto:alberto.p...@gmail.com) wrote:

> IndexReader cannot be accessed from a plugin because it's a private member of RobinEngine. You need to add some code in the elasticsearch code:
> 
> 1. a function in RobinEngine to do your job
> 2. a new action with request, response, transport, ... and add this to the client.
> 
> Hi,  
> Alberto
> 
> Inviato da iPhone
> 
> Il giorno 16/feb/2012, alle ore 21:50, hannescarl [hannesc...@googlemail.com](mailto:hannesc...@googlemail.com) ha scritto:
> 
> > Hello,
> 
> > is it possible to access the IndexReader from the underlying Lucene  
> > Index inside a plugin?  
> > I would like to create an Elasticsearch plugin which accesses a  
> > document directly via the IndexReader.
> 
> > Code example highly appreciated 😉
> 
> > Thanks
> 
> > Hannes

---

<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:38am UTC](https://discuss.elastic.co/t/accessing-indexreader-in-plugin/6734/4 "2017-07-06T03:38:57Z")

</div>


