當前位置: 首頁>>代碼示例>>C#>>正文


C# ConnectionSettings.DisableDirectStreaming方法代碼示例

本文整理匯總了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;
        }
開發者ID:volak,項目名稱:DDD.Enterprise.Example,代碼行數:53,代碼來源:Endpoint.cs


注:本文中的Nest.ConnectionSettings.DisableDirectStreaming方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。