Skip to content

Commit

Permalink
Remove type (#22)
Browse files Browse the repository at this point in the history
* changing from _type Trace to _type _doc to make compatible with ES 6.x

* const for _type, change from _doc to doc
  • Loading branch information
Alex McCool authored Mar 22, 2018
1 parent 7f62aa8 commit fc9222d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions ElasticSearch.Diagnostics/ElasticSearchTraceListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ namespace ElasticSearch.Diagnostics
/// </summary>
public class ElasticSearchTraceListener : TraceListenerBase
{
private const string DocumentType = "doc";

private readonly BlockingCollection<JObject> _queueToBePosted = new BlockingCollection<JObject>();

private IElasticLowLevelClient _client;
Expand Down Expand Up @@ -376,7 +378,7 @@ private async Task WriteDirectlyToES(JObject jo)
{
try
{
await Client.IndexAsync<VoidResponse>(Index, "_doc", jo.ToString());
await Client.IndexAsync<VoidResponse>(Index, DocumentType, jo.ToString());
}
catch (Exception ex)
{
Expand All @@ -389,15 +391,15 @@ private async Task WriteDirectlyToESAsBatch(IEnumerable<JObject> jos)
if (!jos.Any())
return;

var indx = new { index = new { _index = Index, _type = "_doc" } };
var indx = new { index = new { _index = Index, _type = DocumentType } };
var indxC = Enumerable.Repeat(indx, jos.Count());

var bb = jos.Zip(indxC, (f, s) => new object[] { s, f });
var bbo = bb.SelectMany(a => a);

try
{
await Client.BulkPutAsync<VoidResponse>(Index, "_doc", bbo.ToArray(), br => br.Refresh(false));
await Client.BulkPutAsync<VoidResponse>(Index, DocumentType, bbo.ToArray(), br => br.Refresh(false));
}
catch (Exception ex)
{
Expand Down

0 comments on commit fc9222d

Please sign in to comment.