yessql icon indicating copy to clipboard operation
yessql copied to clipboard

How to get document (in separate transaction) after QueryIndex

Open ovekaaven opened this issue 3 months ago • 0 comments

I have an index, and I want a background job to go through each document one by one and process each in a separate transaction. Thus, Query is not useful since it would not use the transaction I want, but I can't quite see how to get DocumentId from the QueryIndex result, either. I'm trying to do something like

var query = await session.QueryIndex<JobIndex>(x => x.Pending).ListAsync();
foreach (var index in query) {
    await session.BeginTransactionAsync();
    var job = session.GetAsync<Job>(index.DocumentId);
    // do stuff
    await session.CommitAsync();
}

Is this possible? The "Id" field in the MapIndex class seems to be unrelated to the document ID.

ovekaaven avatar Apr 06 '24 08:04 ovekaaven