# How to access the underlying Lucene index in ElasticSearch custom handler?

**URL:** <https://discuss.elastic.co/t/how-to-access-the-underlying-lucene-index-in-elasticsearch-custom-handler/744>\
**Category:** Elasticsearch\
**Created:** [May 15, 2015, 10:37am UTC](https://discuss.elastic.co/t/how-to-access-the-underlying-lucene-index-in-elasticsearch-custom-handler/744 "2015-05-15T10:37:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![MJB](https://avatars.discourse-cdn.com/v4/letter/m/ea666f/32.png) [@MJB](https://discuss.elastic.co/u/MJB)\
**Post date:** [May 15, 2015, 10:37am UTC](https://discuss.elastic.co/t/how-to-access-the-underlying-lucene-index-in-elasticsearch-custom-handler/744/1 "2015-05-15T10:37:51Z")

</div>

Cross-posted from [http://stackoverflow.com/questions/30170098/how-to-access-the-underlying-lucene-index-in-elasticsearch-custom-handler](http://stackoverflow.com/questions/30170098/how-to-access-the-underlying-lucene-index-in-elasticsearch-custom-handler) due to a lack of replies.

My current project involves search over highly customised Solr  
indices. It turns out that the best way to query those is to use the  
Lucene API.  
In Solr, I can access the underlying Lucene index using:

```
public void process(ResponseBuilder responseBuilder) throws IOException {
    SolrIndexSearcher sir = responseBuilder.req.getSearcher();
    BooleanQuery bq = new BooleanQuery();
    Query tq = new TermQuery(new Term("content", "test"));
    bq.add(tq, BooleanClause.Occur.MUST);
    TopDocs td = sir.search(bq, 20);
    }

```

Now, ElasticSearch seems to hide the Lucene functionalities. Is there  
a way to expose the Lucene index at ES query handler level, or to query  
it similarly to the example above (i.e. direct querying over index  
fields) using the ES API?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [May 15, 2015, 10:15pm UTC](https://discuss.elastic.co/t/how-to-access-the-underlying-lucene-index-in-elasticsearch-custom-handler/744/2 "2015-05-15T22:15:52Z")

</div>

We don't expose things down to that layer, as far as I understand.

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [May 15, 2015, 11:22pm UTC](https://discuss.elastic.co/t/how-to-access-the-underlying-lucene-index-in-elasticsearch-custom-handler/744/3 "2015-05-15T23:22:21Z")

</div>

You can re-implement Lucene functionalities in an Elasticsearch plugin, if the functionality is really missing. On shard level, much of these can be translated straightforward.

Due to the close relationship of Lucene and Elasticsearch teams, there are many efforts to expose Lucene API to Elasticsearch core features. It would be feasible to study how your custom features can be implemented the "Elastic way" - due to the distributed nature of Elasticsearch, there are important extra efforts to consider, like cluster, shard, and node management.

---

<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:13am UTC](https://discuss.elastic.co/t/how-to-access-the-underlying-lucene-index-in-elasticsearch-custom-handler/744/4 "2017-07-06T00:13:45Z")

</div>


