Пример #1
0
        private async Task <long> IndexAsync(LuceneTextIndexGrain grain)
        {
            var text = new Dictionary <string, string>
            {
                ["iv"] = "Hello World"
            };

            var ids = new Guid[Size];

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

            var watch = ValueStopwatch.StartNew();

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

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

            return(watch.Stop());
        }
Пример #2
0
            private void Index(ContentEvent @event, IndexCommand command)
            {
                command.AppId    = @event.AppId;
                command.SchemaId = @event.SchemaId;

                if (command is UpdateIndexEntry update &&
                    commands.TryGetValue(command.DocId, out var existing) &&
                    existing is UpsertIndexEntry upsert)
                {
                    upsert.ServeAll       = update.ServeAll;
                    upsert.ServePublished = update.ServePublished;
                }