Example #1
0
        private async Task IndexAndSearchAsync(IIndexStorage storage)
        {
            var schemaId = NamedId.Of(Guid.NewGuid(), "my-schema");

            var factory = new IndexManager(storage, new NoopLog());

            var grain = new LuceneTextIndexGrain(factory);

            await grain.ActivateAsync(Guid.NewGuid());

            for (var i = 0; i < M; i++)
            {
                var ids = new Guid[N];

                for (var j = 0; j < ids.Length; j++)
                {
                    ids[j] = Guid.NewGuid();
                }

                foreach (var id in ids)
                {
                    var commands = new IndexCommand[]
                    {
                        new UpsertIndexEntry
                        {
                            ContentId      = id,
                            DocId          = id.ToString(),
                            ServeAll       = true,
                            ServePublished = true,
                            Texts          = texts
                        }
                    };

                    await grain.IndexAsync(schemaId, commands.AsImmutable());
                }

                await grain.CommitAsync();
            }
        }