# How to directly access ElasticSearch index from a plugin

**URL:** <https://discuss.elastic.co/t/how-to-directly-access-elasticsearch-index-from-a-plugin/22081>\
**Category:** Elasticsearch\
**Created:** [February 11, 2015, 1:55am UTC](https://discuss.elastic.co/t/how-to-directly-access-elasticsearch-index-from-a-plugin/22081 "2015-02-11T01:55:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tao\_Cheng](https://avatars.discourse-cdn.com/v4/letter/t/d07c76/32.png) [@Tao\_Cheng](https://discuss.elastic.co/u/Tao_Cheng)\
**Post date:** [February 11, 2015, 1:55am UTC](https://discuss.elastic.co/t/how-to-directly-access-elasticsearch-index-from-a-plugin/22081/1 "2015-02-11T01:55:44Z")

</div>

Hi all,

I want to directly access low level ElasticSearch (or in other words  
Lucene) index from a plugin, so that I can say iterate through an inverted  
index of a keyword in the plugin. I know from ElasticSearch source code one  
can access the ContextIndexSearcher instance (which has an IndexReader  
member) from SearchService to directly access the inverted index. However,  
I could not figure out how to get the handle to either the  
ContextIndexSearcher instance or the SearchService instance from a plugin.  
Any suggestion here will be highly appreciated!

Thanks,

-Tao

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/1643df27-bb92-429b-acf0-d4cdcf85c545%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/1643df27-bb92-429b-acf0-d4cdcf85c545%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [February 11, 2015, 6:01am UTC](https://discuss.elastic.co/t/how-to-directly-access-elasticsearch-index-from-a-plugin/22081/2 "2015-02-11T06:01:06Z")

</div>

I think you can try to inject the SearchService in the plugin?

Have a look at this. We inject here another service. [https://github.com/elasticsearch/elasticsearch-mapper-attachments/blob/master/src/main/java/org/elasticsearch/index/mapper/attachment/RegisterAttachmentType.java](https://github.com/elasticsearch/elasticsearch-mapper-attachments/blob/master/src/main/java/org/elasticsearch/index/mapper/attachment/RegisterAttachmentType.java)

HTH

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

> Le 11 févr. 2015 à 02:55, Tao Cheng [tcheng3@gmail.com](mailto:tcheng3@gmail.com) a écrit :
> 
> Hi all,
> 
> I want to directly access low level Elasticsearch (or in other words Lucene) index from a plugin, so that I can say iterate through an inverted index of a keyword in the plugin. I know from Elasticsearch source code one can access the ContextIndexSearcher instance (which has an IndexReader member) from SearchService to directly access the inverted index. However, I could not figure out how to get the handle to either the ContextIndexSearcher instance or the SearchService instance from a plugin. Any suggestion here will be highly appreciated!
> 
> Thanks,
> 
> ## -Tao
> 
> 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).  
> To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/1643df27-bb92-429b-acf0-d4cdcf85c545%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/1643df27-bb92-429b-acf0-d4cdcf85c545%40googlegroups.com).  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/AC9F5363-0DAD-423F-8975-FCEF4A04EEFE%40pilato.fr](https://groups.google.com/d/msgid/elasticsearch/AC9F5363-0DAD-423F-8975-FCEF4A04EEFE%40pilato.fr).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 12:33am UTC](https://discuss.elastic.co/t/how-to-directly-access-elasticsearch-index-from-a-plugin/22081/3 "2017-07-06T00:33:41Z")

</div>


