Beispiel #1
0
 private static IEnumerable <Func <object> > DocumentCommandsAsync(IElasticClient elastic)
 {
     return(new List <Func <object> >
     {
         () => elastic.BulkAsync(
             new BulkRequest("test_index")
         {
             Operations = new List <IBulkOperation>
             {
                 new BulkCreateOperation <Post>(new Post {
                     Id = 1, Title = "BulkCreateOperation"
                 })
             }
         }),
         () => elastic.CreateAsync(new CreateRequest <Post>(new Post {
             Id = 2, Title = "CreateRequest"
         }, "test_index")),
         () => elastic.CreateDocumentAsync(new Post {
             Id = 3, Title = "CreateDocument"
         }),
         () => elastic.CountAsync <Post>(),
         () => elastic.SearchAsync <Post>(s => s.MatchAll()),
         () => elastic.DeleteByQueryAsync(new DeleteByQueryRequest("test_index")
         {
             Size = 0
         })
     });
 }
Beispiel #2
0
        public async Task Store(PlayerFeedbackDto feedback)
        {
            var feedbackDocument = PlayerFeedbackDocument.CreateFromDto(feedback);
            var creationResult   = await _elasticClient.CreateDocumentAsync(feedbackDocument);

            if (creationResult.IsValid)
            {
                return;
            }

            if (creationResult.ServerError.Error.Type == ElasticsearchError.DocumentVersionConflictError)
            {
                throw DuplicateFeedbackException.Create(feedback.SessionId, feedback.PlayerId, feedback.Timestamp);
            }

            var unexpectedError = ElasticsearchError.GenerateMessageForPlayerFeedbackInsertionError(feedback);

            throw new UnexpectedFeedbackInsertionException(unexpectedError, creationResult.OriginalException);
        }
Beispiel #3
0
        // METHODS
        public async Task <PhotoDocument> CreateAsync(PhotoDocument item)
        {
            await _elasticClient.CreateDocumentAsync(item);

            return(item);
        }