You are currently browsing legacy 4.0 version of documentation. Click here to switch to the newest 5.1 version.

We can help you with migration to the latest RavenDB

Contact Us Now
see on GitHub

Indexes: Indexing LINQ Extensions

Various indexing LINQ extensions are available to enhance the usability and reduce the complexity of the indexing functions. The available extensions are:


You can read more about boosting here.


Strings and enumerables can be reversed by using Reverse extension.

public static class Employees_ByReversedFirstName extends AbstractIndexCreationTask {
    public Employees_ByReversedFirstName() {
        map = "docs.Employees.Select(employee => new { " +
            "    FirstName = employee.FirstName.Reverse() " +
List<Employee> results = session
    .query(Employee.class, Employees_ByReversedFirstName.class)
    .whereEquals("FirstName", "treboR")


WhereEntityIs can be used to check if given Raven-Entity-Name value in metadata for the given document matches any of the given values. This can be useful when indexing polymorphic data. Please visit our dedicated article to get more information (or click here).


IfEntityIs is similar to WhereEntityIs, yet it checks only against one value.

Parsing numbers

String values can be safely parsed to int, long, decimal and double using the appropriate methods:

  • ParseInt,
  • ParseLong,
  • ParseDecimal,
  • ParseDouble

There are two overrides for each method: The first one returns the default value in case of parsing failure. The second one accepts the value that should be returned when failure occurs.

public static class Item_Parse extends AbstractIndexCreationTask {
    public static class Result {
        private int majorWithDefault;
        private int majorWithCustomDefault;

        public int getMajorWithDefault() {
            return majorWithDefault;

        public void setMajorWithDefault(int majorWithDefault) {
            this.majorWithDefault = majorWithDefault;

        public int getMajorWithCustomDefault() {
            return majorWithCustomDefault;

        public void setMajorWithCustomDefault(int majorWithCustomDefault) {
            this.majorWithCustomDefault = majorWithCustomDefault;

    public Item_Parse() {
        map = "docs.Items.Select(item => new {" +
            "    item = item, " +
            "    parts = item.version.Split('.', System.StringSplitOptions.None) " +
            "}).Select(this0 => new { " +
            "    majorWithDefault =[0].ParseInt(), " + // will return default(int) in case of parsing failure
            "    majorWithCustomDefault =[0].ParseInt(-1) " + // will return -1 in case of parsing failure

public static class Item {
    private String version;

    public String getVersion() {
        return version;

    public void setVersion(String version) {
        this.version = version;
Item item1 = new Item();

Item item2 = new Item();


List<Item_Parse.Result> results = session
    .query(Item_Parse.Result.class, Item_Parse.class)

Assert.assertEquals(2, results.size());
Assert.assertTrue( -> x.getMajorWithDefault() == 3));
Assert.assertTrue( -> x.getMajorWithCustomDefault() == 3));
Assert.assertTrue( -> x.getMajorWithDefault() == 0));
Assert.assertTrue( -> x.getMajorWithCustomDefault() == -1));



Default storage value for the storeAllFields() method is FieldStorage.NO. Keep in mind that storing fields will increase disk space usage.