C# Node.JS
Article For
1.0 2.0 2.5 3.0 3.5 4.0 4.2 5.0 5.1 5.2

Indexes: Storing Data in Index

Once the tokenization and analysis process is completed, the resulting tokens, created according to the used analyzer, are stored in the index. By default, tokens saved in the index are available for searching. but their original field values aren't stored.

Lucene allows you to store the original field text (before it is analyzed) as well. This feature is exposed in the index definition object as the Storage property of the IndexFieldOptions.

Enabling field storing causes original values will be available for retrieval when doing projections.

public static class Employees_ByFirstAndLastName extends AbstractIndexCreationTask {
    public Employees_ByFirstAndLastName() {
        map =  "docs.Employees.Select(employee => new {" +
            "    FirstName = employee.FirstName," +
            "    LastName = employee.LastName" +

        store("FirstName", FieldStorage.YES);
        store("LastName", FieldStorage.YES);
IndexDefinition indexDefinition = new IndexDefinition();
indexDefinition.setMaps(Collections.singleton("docs.Employees.Select(employee => new {" +
    "    FirstName = employee.FirstName," +
    "    LastName = employee.LastName" +

java.util.Map<String, IndexFieldOptions> fields = new HashMap<>();

IndexFieldOptions firstNameOptions = new IndexFieldOptions();
fields.put("FirstName", firstNameOptions);

IndexFieldOptions lastNameOptions = new IndexFieldOptions();
fields.put("LastName", lastNameOptions);

    .send(new PutIndexesOperation(indexDefinition));



Default Storage value for each field is FieldStorage.NO. Keep in mind that storing fields will increase disk space usage.


If the projection requires only the fields that are stored, then the document will not be loaded from the storage and the query results will come directly from the index. This can increase query performance at the cost of disk space used.