• Returns a Search session handle for reading and writing key-value data on the workflow's backend HASH record. Search fields are flat string key-value pairs stored alongside the job state, making them queryable via Durable.Client.workflow.search() (FT.SEARCH).

    Each call produces a unique session ID tied to the deterministic execution counter, ensuring correct replay behavior.

    Use search() for flat, indexable key-value data. For structured JSON documents, use entity() instead.

    import { Durable } from '@hotmeshio/hotmesh';

    export async function orderWorkflow(orderId: string): Promise<void> {
    const search = await Durable.workflow.search();

    // Write searchable fields
    await search.set({
    orderId,
    status: 'processing',
    createdAt: new Date().toISOString(),
    });

    const { processOrder } = Durable.workflow.proxyActivities<typeof activities>();
    await processOrder(orderId);

    // Update status
    await search.set({ status: 'completed' });

    // Read a field back
    const status = await search.get('status');
    }
    // Increment a numeric counter
    export async function counterWorkflow(): Promise<number> {
    const search = await Durable.workflow.search();
    await search.set({ count: '0' });
    await search.incr('count', 1);
    await search.incr('count', 1);
    return Number(await search.get('count')); // 2
    }

    Returns Promise<Search>

    A search session scoped to the current workflow job.