本文整理汇总了C#中Nest.ConnectionSettings.DisableDirectStreaming方法的典型用法代码示例。如果您正苦于以下问题:C# ConnectionSettings.DisableDirectStreaming方法的具体用法?C# ConnectionSettings.DisableDirectStreaming怎么用?C# ConnectionSettings.DisableDirectStreaming使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nest.ConnectionSettings
的用法示例。
在下文中一共展示了ConnectionSettings.DisableDirectStreaming方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConfigureElastic
public static IElasticClient ConfigureElastic()
{
Logger.Info("Setting up Elastic");
var connectionString = ConfigurationManager.ConnectionStrings["Elastic"];
if (connectionString == null)
throw new ArgumentException("No elastic connection string found");
var data = connectionString.ConnectionString.Split(';');
var url = data.FirstOrDefault(x => x.StartsWith("Url", StringComparison.CurrentCultureIgnoreCase));
if (url == null)
throw new ArgumentException("No URL parameter in elastic connection string");
var index = data.FirstOrDefault(x => x.StartsWith("DefaultIndex", StringComparison.CurrentCultureIgnoreCase));
if (string.IsNullOrEmpty(index))
throw new ArgumentException("No DefaultIndex parameter in elastic connection string");
index = index.Substring(13);
var node = new Uri(url.Substring(4));
var pool = new Elasticsearch.Net.SingleNodeConnectionPool(node);
var regex = new Regex("([+\\-!\\(\\){}\\[\\]^\"~*?:\\\\\\/>< ]|[&\\|]{2}|AND|OR|NOT)", RegexOptions.Compiled);
var settings = new Nest.ConnectionSettings(pool, (_) => new JsonNetSerializer(_))
.DefaultIndex(index)
.DefaultTypeNameInferrer(type =>
type.FullName
.Replace("Pulse.Presentation.ServiceStack.", "")
.Replace("Pulse.Application.Elastic.", "")
.Replace('.', '_')
)
.DefaultFieldNameInferrer(field => regex.Replace(field, ""));
#if DEBUG
settings = settings.DisableDirectStreaming();
#endif
var client = new ElasticClient(settings);
if (!client.IndexExists(index).Exists)
client.CreateIndex(index, i => i
.Settings(s => s
.NumberOfShards(8)
.NumberOfReplicas(0)
.Analysis(analysis => analysis
.TokenFilters(f => f.NGram("ngram", d => d.MinGram(1).MaxGram(15)))
.Analyzers(a => a
.Custom("default_index", t => t.Tokenizer("keyword").Filters(new[] { "standard", "lowercase", "asciifolding", "kstem", "ngram" }))
.Custom("suffix", t => t.Tokenizer("keyword").Filters(new[] { "standard", "lowercase", "asciifolding", "reverse" }))
)
)));
return client;
}