indexes: Indexing Counters
-
To index counters, create a static index that inherits from
AbstractCountersIndexCreationTask
. -
Auto-indexes for counters are not available at this time.
-
In this page:
Usage
In order to index counter values, create an index that inherits from AbstractCountersIndexCreationTask
.
Next, choose one of these two methods which take the index expression:
this.maps = new Set(["map"]);
this.map("map");
maps
indexes all the counters in the indexed documents. addMap
only indexes the counters with
the specified name.
Examples of indexes using each method:
class MyCounterIndex extends AbstractCountersIndexCreationTask {
constructor() {
super();
this.map = "counters.Companies.HeartRate.Select(counter => new {\n" +
" heartBeat = counter.Value,\n" +
" name = counter.Name,\n" +
" user = counter.DocumentId\n" +
"})";
}
}
Querying the Index
const companies = session
.query({index: "Companies_ByCounterNames"})
.containsAny("counterNames", ["Likes"])
let results = await companies.all();