# What is the exactly content like in a index file in elasticsearch

**URL:** https://discuss.elastic.co/t/what-is-the-exactly-content-like-in-a-index-file-in-elasticsearch/1894
**Category:** Elasticsearch
**Created:** [June 4, 2015, 2:33am UTC](https://discuss.elastic.co/t/what-is-the-exactly-content-like-in-a-index-file-in-elasticsearch/1894 "2015-06-04T02:33:02Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Daniel\_C\_S\_Yeh](https://avatars.discourse-cdn.com/v4/letter/d/c6cbf5/32.png) [@Daniel\_C\_S\_Yeh](https://discuss.elastic.co/u/Daniel_C_S_Yeh)
#### Post date: [June 4, 2015, 2:33am UTC](https://discuss.elastic.co/t/what-is-the-exactly-content-like-in-a-index-file-in-elasticsearch/1894/1 "2015-06-04T02:33:02Z")

</div>

Dear all,

I have fully understood the mechanism of indexing a document in elasticsearch, like the example here

[https://www.elastic.co/guide/en/elasticsearch/guide/current/inverted-index.html](https://www.elastic.co/guide/en/elasticsearch/guide/current/inverted-index.html)

but one more question is what is the exactly content in the index file?

and how can I open it to see the dictionary table?

Many thanks

---

<div class="post-metadata">

### Author: ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)
#### Post date: [June 4, 2015, 1:04pm UTC](https://discuss.elastic.co/t/what-is-the-exactly-content-like-in-a-index-file-in-elasticsearch/1894/2 "2015-06-04T13:04:47Z")

</div>

While it doesn't answer all of your questions I like this page:  
[http://lucene.apache.org/core/4\_5\_0/core/org/apache/lucene/codecs/lucene45/package-summary.html](http://lucene.apache.org/core/4_5_0/core/org/apache/lucene/codecs/lucene45/package-summary.html)

---

<div class="post-metadata">

### Author: ![Jason\_Wee](https://avatars.discourse-cdn.com/v4/letter/j/7ea924/32.png) [@Jason\_Wee](https://discuss.elastic.co/u/Jason_Wee)
#### Post date: [June 4, 2015, 1:59pm UTC](https://discuss.elastic.co/t/what-is-the-exactly-content-like-in-a-index-file-in-elasticsearch/1894/3 "2015-06-04T13:59:48Z")

</div>

```
	IndexReader indexReader = DirectoryReader.open(FSDirectory.open(new File("clean/index.termrange")));

	// all fields
	SlowCompositeReaderWrapper.wrap(indexReader).getFieldInfos().forEach(x -> System.out.println(x.name));
	
	Terms terms = SlowCompositeReaderWrapper.wrap(indexReader).terms("contents");
	
	TermsEnum iter = terms.iterator(null);
	
	BytesRef byteRef = null;
    while((byteRef = iter.next()) != null) {
        String term = new String(byteRef.bytes, byteRef.offset, byteRef.length);
        
        System.out.format("%-10s:%2d:%2d %n", term, indexReader.docFreq(new Term("contents", term)), indexReader.totalTermFreq(new Term("contents", term)));
    }
    
	System.out.println(terms.getSumTotalTermFreq());
	System.out.println(terms.getSumDocFreq());
	System.out.println(indexReader.getSumTotalTermFreq("contents"));

```

lucene index files are binary.. hexdump cannot really print something useful, you need to write code to read the index from the directory. then loop through the term and get the frequency from the index reader object.

hth

jason

---

<div class="post-metadata">

### Author: ![colings86](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/colings86/32/44960_2.png) [@colings86](https://discuss.elastic.co/u/colings86)
#### Post date: [June 4, 2015, 2:06pm UTC](https://discuss.elastic.co/t/what-is-the-exactly-content-like-in-a-index-file-in-elasticsearch/1894/4 "2015-06-04T14:06:28Z")

</div>

I haven't used it for a while but Luke used to be a good UI app for inspecting Lucene indices and the seems to support inspecting Elasticsearch indices now too.

Disclaimer: I have not run Luke since it was hosted on Google Code.

IMPORTANT: I would definitely copy the indices to a new folder (outside of you ES directory) and point Luke at that copy to make sure it doesn't corrupt the index somehow.

> **[DmitryKey/luke](https://github.com/DmitryKey/luke)**
>
> luke - This is mavenised Luke: Lucene Toolbox Project

---

<div class="post-metadata">

### Author: ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)
#### Post date: [June 4, 2015, 2:28pm UTC](https://discuss.elastic.co/t/what-is-the-exactly-content-like-in-a-index-file-in-elasticsearch/1894/5 "2015-06-04T14:28:37Z")

</div>

> [@Jason\_Wee](#):
>
> lucene index files are binary.. hexdump cannot really print something useful, you need to write code to read the index from the directory. then loop through the term and get the frequency from the index reader object.

I don't know if this solution is the "right way to do it in general but it will work. And teach you some things.

You probably want to be careful of that `new String` call there - I don't think it'll work properly. I'd go with `BytesRef.utf8ToString` or `UnicodeUtil.UTF8toUTF16`.

---

<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:09am UTC](https://discuss.elastic.co/t/what-is-the-exactly-content-like-in-a-index-file-in-elasticsearch/1894/6 "2017-07-06T00:09:36Z")

</div>


