Click or drag to resize

IMapTKey, TValueAddIndex Method

Adds an index to this map for the specified entries so that queries can run faster.

Namespace:  Hazelcast.Core
Assembly:  Hazelcast.Net (in Hazelcast.Net.dll) Version: 3.11
Syntax
void AddIndex(
	string attribute,
	bool ordered
)

Parameters

attribute
Type: SystemString
attribute of value
ordered
Type: SystemBoolean
true if index should be ordered, false otherwise.
Remarks
Adds an index to this map for the specified entries so that queries can run faster.

Let's say your map values are Employee objects.

public class Employee :IPortable
{
    private bool active = false;
    private int age;
    private string name = null;
    // other fields.

}

If you are querying your values mostly based on age and active then you should consider indexing these fields.

var imap = Hazelcast.GetMap("employees");
imap.AddIndex("age", true);        // ordered, since we have ranged queries for this field
imap.AddIndex("active", false);    // not ordered, because boolean field cannot have range

Index attribute should either have a getter method or be public. You should also make sure to add the indexes before adding entries to this map.

See Also