| 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
)
Sub AddIndex (
attribute As String,
ordered As Boolean
)
void AddIndex(
String^ attribute,
bool ordered
)
abstract AddIndex :
attribute : string *
ordered : bool -> unit
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;
}
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);
imap.AddIndex("active", false);
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