Indexes: Indexing Compare Exchange Values

  • Compare exchange values can be loaded within an index using the value's key.

  • The index will update when the compare exchange value is updated, as well as when documents are modified in the indexed collection(s).

  • In this page:


For javascript indexes, use the method cmpxchg(<key>).
Parameter Type Description
key string The key of a particular compare exchange value.


These indexes map the rooms in a hotel, as well as compare exchange values representing the guests in those rooms.

class Compare_Exchange_Index extends AbstractCsharpIndexCreationTask {
    constructor() {
        super(); = `docs.HotelRooms.Select(room => new { 
                         RoomID = room.RoomID,     
                         Guests = cmpxchg(room.RoomID)

Querying the Index

const VIPRooms = await session
    "   from Hotelrooms as room\n"+
    "   where room.Guests == cmpxchg('VIP')"