public bool Index(IEnumerable <EsDocument> docs) { StringBuilder bulkBodyBuilder = new StringBuilder(); foreach (var doc in docs) { var newDoc = new EsDocument(_config.Index, _config.Type, doc.Data); bulkBodyBuilder.AppendLine( new JObject( new JProperty("index", new JObject( new JProperty("_index", newDoc.Index), new JProperty("_type", newDoc.Type), new JProperty("_id", newDoc.Id)))).ToString(Newtonsoft.Json.Formatting.None)); bulkBodyBuilder.AppendLine(newDoc.Data.ToString(Newtonsoft.Json.Formatting.None)); } var bulkBody = bulkBodyBuilder.ToString(); if (!string.IsNullOrWhiteSpace(bulkBody)) { return(_client.Bulk(bulkBody)); } return(true); }
private string BuildDocIndexJsonChrome(EsDocument doc) { return(string.Format( @"{{""index"":{{""_index"":""{0}"",""_type"":""{1}"",""_id"":""{2}""}}}} {3} ", _mockConfig.Object.Index, _mockConfig.Object.Type, doc.Id, doc.Data.ToString(Newtonsoft.Json.Formatting.None))); }
public void BulkIndex_addsMultipleDoc_Successfully( EsDocument doc1, EsDocument doc2, EsDocument doc3, EsTestIndexClient testClient, IndexWorker indexWorker) { indexWorker .Index(new[] { doc1, doc2, doc3 }) .Should().Be(true); using (testClient.ForTestAssertions()) { testClient.GetAllDocs().Should().HaveCount(3); } }
public void BulkIndex_addsSingleDoc_Successfully( EsDocument doc1, EsTestIndexClient testClient, IndexWorker indexWorker) { indexWorker .Index(new List <EsDocument>() { doc1 }) .Should().Be(true); using (testClient.ForTestAssertions()) { testClient.GetAllDocs().Single().ToString().Should().Be(doc1.Data.ToString()); } }
public void ScrollPage_MultipleDocsExistOnSingleScrollPage_ReturnsDocs( EsDocument doc1, EsDocument doc2, EsDocument doc3, IndexWorker indexWorker, EsTestIndexClient testClient, ScrollWorker scrollWorker) { indexWorker.Index(new [] { doc1, doc2, doc3 }); using (testClient.ForTestAssertions()) { var actuals = scrollWorker.ScrollPage(); actuals.Should().NotBeNull(); actuals.Should().HaveCount(3); } }
private static EsDocument GetDocument() { EsDocument pd = new EsDocument(); pd.PageSize = "A4"; pd.PageMargins = new EsMargins() { Top = 20, Bottom = 20, Left = 20, Right = 20 }; EsSection s = new EsSection(); pd.Sections.Add(s); s.Elements.Add( new EsImage() { Base64 = Convert.ToBase64String(ResourcesHelper.GetBin("Resources.Logo.png")), HorizontalAlign = EsHorizontalAlign.Center, Width = 75 } ); s.Elements.Add( new EsText() { Content = "Overview", FontName = "Verdana", FontSize = 20, TextAlign = EsTextAlign.Right } ); s.Elements.Add( new EsText() { Content = ResourcesHelper.GetText("Resources.Overview.txt"), FontSize = 10, TextAlign = EsTextAlign.Justified } ); return(pd); }
private static string GetDocSerialized() { EsDocument pd = GetDocument(); return(EsGenerator.SerializeDocument(pd)); }
public EsDocument GetCorrespondingDoc(EsDocument seedDoc) { var doc = _client.Get <JObject>(seedDoc.Index, seedDoc.Type, seedDoc.Id); return(new EsDocument(seedDoc.Index, seedDoc.Type, doc)); }