コード例 #1
0
        public async Task UpsertDocument(string docId, string doc)
        {
            var postData = PostData.String($"{{ \"doc\": {doc}, \"doc_as_upsert\" : true }}");
            var result   = await elasticClient.UpdateAsync <StringResponse>(
                this.elasticSearchConfig.ELASTIC_SEARCH_INDEX_NAME,
                this.elasticSearchConfig.ELASTIC_SEARCH_INDEX_TYPE_NAME,
                docId, postData);

            this.HandleErrors(result);
        }
コード例 #2
0
        public async Task UpdateBook(Book book)
        {
            var response = await _client.UpdateAsync <StringResponse>(
                IndexName,
                book.Id.ToString(),
                PostData.Serializable(new
            {
                doc = book
            }));

            if (!response.Success)
            {
                throw response.OriginalException;
            }
        }