当前位置: 首页>>代码示例>>C#>>正文


C# ConnectionSettings.SetDefaultIndex方法代码示例

本文整理汇总了C#中Nest.ConnectionSettings.SetDefaultIndex方法的典型用法代码示例。如果您正苦于以下问题:C# ConnectionSettings.SetDefaultIndex方法的具体用法?C# ConnectionSettings.SetDefaultIndex怎么用?C# ConnectionSettings.SetDefaultIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Nest.ConnectionSettings的用法示例。


在下文中一共展示了ConnectionSettings.SetDefaultIndex方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReIndexAll

        public ActionResult ReIndexAll()
        {
            var documents = db.Documents.ToList();

            var uriString = ConfigurationManager.AppSettings["SEARCHBOX_URL"];
            var searchBoxUri = new Uri(uriString);

            var settings = new ConnectionSettings(searchBoxUri);
            settings.SetDefaultIndex("sample");

            var client = new ElasticClient(settings);

            // delete index if exists at startup
            if (client.IndexExists("sample").Exists)
            {
                client.DeleteIndex("sample");
            }

            // Create a new "sample" index with default settings
            client.CreateIndex("sample", new IndexSettings());

            // Index all documents
            client.IndexMany<Document>(documents);

            ViewBag.Message = "Reindexing all database is complete!";

            return RedirectToAction("Index");
        }
开发者ID:rlugojr,项目名称:.net-sample,代码行数:28,代码来源:DocumentManagementController.cs

示例2: BlackListDataManager

 public BlackListDataManager()
 {
     try
     {
         var elasticSearchUrl = ConfigurationManager.AppSettings["ElasticStoreConnection"];
         var index = ConfigurationManager.AppSettings["EIndex_BlackList"];
         _settings =
             new ConnectionSettings(new Uri(elasticSearchUrl)).SetDefaultIndex(index).PluralizeTypeNames();
         _client = new ElasticClient(_settings);
         var isIndexExist = _client.IndexExists(i => i.Index(index));
         if (!isIndexExist.Exists)
         {
             _client.CreateIndex(c => c.Index(index));
             _settings.SetDefaultIndex(index);
             _client = new ElasticClient(_settings);
         }
         var response =
             _client.Map<BlockedUser>(
                 h =>
                     h.MapFromAttributes(10).Properties(p => p
                         .String(s => s.Name(i => i.ByEmail).Index(FieldIndexOption.NotAnalyzed))
                         .String(s => s.Name(i => i.ToEmail).Index(FieldIndexOption.NotAnalyzed))
                         ));
         IsServerError(response);
     }
     catch (Exception ex)
     {
         Logger.LogException(ex, _soruce, "BlackListDataManager", Severity.Critical);
         throw;
     }
 }
开发者ID:TokleMahesh,项目名称:BG,代码行数:31,代码来源:BlackListDataManager.cs

示例3: GameDataManager

 public GameDataManager()
 {
     try
     {
         var elasticSearchUrl = ConfigurationManager.AppSettings["ElasticStoreConnection"];
         var index = ConfigurationManager.AppSettings["EIndex_Game"];
         _settings =
             new ConnectionSettings(new Uri(elasticSearchUrl)).SetDefaultIndex(index).PluralizeTypeNames();
         _client = new ElasticClient(_settings);
         var isIndexExist = _client.IndexExists(i => i.Index(index));
         if (!isIndexExist.Exists)
         {
             _client.CreateIndex(c => c.Index(index));
             _settings.SetDefaultIndex(index);
             _client = new ElasticClient(_settings);
         }
         var response =
             _client.Map<Game>(
                 h =>
                     h.Properties(p => p
                         .String(s => s.Name(i => i.GameId).Index(FieldIndexOption.NotAnalyzed))
                         .String(s => s.Name(i => i.Status).Index(FieldIndexOption.NotAnalyzed))
                         .String(s => s.Name(i => i.TurnOfPlayer).Index(FieldIndexOption.NotAnalyzed))
                         .Object<Winner>(o => o.Name(w => w.Winner).Properties(wp => wp.String(f => f.Name(l => l.FacebookId).Index(FieldIndexOption.NotAnalyzed)))
                         )));
         IsServerError(response);
     }
     catch (Exception ex)
     {
         Logger.LogException(ex, _source, "GameDataManager", Severity.Critical);
         throw;
     }
 }
开发者ID:TokleMahesh,项目名称:BG,代码行数:33,代码来源:GameDataManager.cs

示例4: GetClient

        public IElasticClient GetClient(IElasticConnectionSettings settings)
        {
            if (settings == null) throw new ArgumentNullException("settings");

            var connectionSettings = new ConnectionSettings(settings.Host, settings.Port);
            connectionSettings.SetDefaultIndex(settings.IndexName);
            return new ElasticClient(connectionSettings);
        }
开发者ID:AdaTheDev,项目名称:ElasticTweets,代码行数:8,代码来源:ClientProvider.cs

示例5: ConfigureApplicationContainer

 protected override void ConfigureApplicationContainer(TinyIoCContainer container)
 {
     container.Register<IAutocompleteFinder, AutocompleteFinder>();
     container.Register<IElasticClient>((ctr, param) =>
     {
         var connectionSettings = new ConnectionSettings(new Uri("http://172.31.170.182:9200/"));
         connectionSettings.SetDefaultIndex("autocomplete");
         return new ElasticClient(connectionSettings);
     });
 }
开发者ID:azdlowry,项目名称:Autocomplete,代码行数:10,代码来源:Bootstrapper.cs

示例6: GetClient

        protected ElasticClient GetClient()
        {
            if (_client == null)
            {

                var elasticSettings = new ConnectionSettings("127.0.0.1.", 9200);
                elasticSettings.SetDefaultIndex(index);
                _client = new ElasticClient(elasticSettings);
            }
            return _client;
        }
开发者ID:richardwilly98,项目名称:test-angular-js,代码行数:11,代码来源:DocumentService.cs

示例7: EsClient

        /// Constructor
        public EsClient()
        {
            var node = new Uri(ElasticUri);

            _settings = new ConnectionSettings(node);
            _settings.SetDefaultIndex(ConfigurationManager.AppSettings["DefaultIndex"]);
            _settings.MapDefaultTypeNames(m => m.Add(typeof(HadoopMetaDataModels), ConfigurationManager.AppSettings["DefaultIndexType"]));

            Current = new ElasticClient(_settings);
            Current.Map<HadoopMetaDataModels>(m => m
                .MapFromAttributes());
            
        }
开发者ID:tjdurant,项目名称:DataEntryWebForm,代码行数:14,代码来源:ElasticClient.cs

示例8: CreateClient

        public static IElasticClient CreateClient(IContainer container)
        {
            var configuration = ClientConfigurationSection.GetConfiguration();
            var connectionSettings = new ConnectionSettings(
                new Uri(configuration.ElasticSearchUrl)
            );

            ConfigureIdProperty(connectionSettings);
            connectionSettings.SetJsonSerializerSettingsModifier(x => {
                x.Converters = ContentIndexer.Instance.IndexingConventions.JsonConverters;
                x.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
            });
            connectionSettings.SetDefaultTypeNameInferrer(x => typeof(IContent).IsAssignableFrom(x) ? Constants.EPiServerContentTypeName : null);
            connectionSettings.SetDefaultIndex(container.GetInstance<IndexResolver>().ResolveIndex());
            connectionSettings.ExposeRawResponse();
            container.Configure(x => x.For<ConnectionSettings>().Use(connectionSettings));

            return new ElasticClient(connectionSettings, null, new PreSerializationProccessor(connectionSettings));
        }
开发者ID:kneeclass,项目名称:ElasticEPi,代码行数:19,代码来源:SearchClientFactory.cs

示例9: ConfigureElasticClient

        public void ConfigureElasticClient()
        {
            //var setting = new ConnectionSettings(new Uri("http://localhost:9200/"),Constants.INDEX_PERSON);
            //setting.EnableTrace();
            //setting.ExposeRawResponse();
            //client = new ElasticClient(setting);

            var node = new Uri(Constants.ELASTIC_SEARCH_URI);

           var settings = new ConnectionSettings(node);
            settings.SetDefaultIndex(Constants.INDEX_PERSON);
            settings.MapDefaultTypeNames(m => m.Add(typeof(Person), (Constants.INDEX_PERSON)));

            client = new ElasticClient(settings);

            client.CreateIndex(ci => ci
                .Index(Constants.INDEX_PERSON)
                .AddMapping<Person>(m => m.MapFromAttributes()));
        }
开发者ID:OctavianHome,项目名称:angularjs,代码行数:19,代码来源:HelperElasticSearch.cs

示例10: GetClientsBy

        public List<ClientInformation> GetClientsBy(string name, bool? onlyPossiblyStolen)
        {
            ElasticClient esClient;
                        
            var settings = new ConnectionSettings(new Uri("http://localhost:9200"));
            settings.SetDefaultIndex(INDEX);

            esClient = new ElasticClient(settings);

            //text is always in lowercase in ES
            if (!string.IsNullOrEmpty(name))
                name = name.ToLowerInvariant();

            var result = esClient.Search<ClientInformation>(
               sd => sd.Query(  q=> q.Strict(false).Wildcard(t => t.Name,name))
                   .Filter(f => 
                       f.Strict(false).Term(t => t.PossiblyStolen, onlyPossiblyStolen))                  
                   
                   );

            return result.Documents.ToList();
        }
开发者ID:mojamcpds,项目名称:CQRS-NServiceBus-EventStore-ElasticSearch,代码行数:22,代码来源:ClientInformationRepository.cs

示例11: Main

        static void Main(string[] args)
        {
            var reader = new StreamReader("C:/data/logs/FritzLog.csv");
            var csv = new CsvReader(reader);
            csv.Parser.Configuration.Delimiter = ";";
            csv.Configuration.HasHeaderRecord = true;
            csv.Configuration.IgnoreHeaderWhiteSpace = true;

            var records = csv.GetRecords<LogEntry>();

            var node = new Uri("http://localhost:9200");
            var settings = new ConnectionSettings(node);
            settings.SetDefaultIndex("phonelog");
          
            var client = new ElasticClient(settings);
            client.DeleteIndex("phonelog");
            client.CreateIndex(ci => ci.Index("phonelog").AddMapping<LogEntry>(m => m.MapFromAttributes()));
            foreach (var record in records)
            {
                var result = client.Index(record);
                Console.WriteLine(record + ", Result: " + result);
            }

        }
开发者ID:serafinho,项目名称:LoggerTest,代码行数:24,代码来源:Program.cs

示例12: AdventureLocationRepository

 public AdventureLocationRepository()
 {
     var setting = new ConnectionSettings("office.mtctickets.com", 9200);
     setting.SetDefaultIndex("pins");
     client = new ElasticClient(setting);
 }
开发者ID:JoeHosman,项目名称:HTA,代码行数:6,代码来源:AdventureLocationRepository.cs

示例13: Insert

        internal bool Insert(ad_network obj)
        {
            var connectionSettings = new ConnectionSettings(MainVariables.conElasticSearch);
            connectionSettings.SetDefaultIndex("ad_network");

            var elasticClient = new ElasticClient(connectionSettings);
            //var indexaaa = elasticClient.DeleteIndex("advertisement");
            var index = elasticClient.Index(obj);
            if (index.ServerError == null) return true;
            else return false;
        }
开发者ID:azhard4int,项目名称:crawlers,代码行数:11,代码来源:ModelFbDetail.cs

示例14: Index

        private static void Index(DocumentModel document, String operation)
        {
            var uriString = ConfigurationManager.AppSettings["SEARCHBOX_URL"];
            var searchBoxUri = new Uri(uriString);

            var settings = new ConnectionSettings(searchBoxUri);
            settings.SetDefaultIndex(indexName);

            var client = new ElasticClient(settings);

            if (!client.IndexExists(indexName).Exists)
            {
                // Create a new "sample" index with default settings
                ICreateIndexRequest iCreateIndexReq = new CreateIndexRequest(indexName);
                iCreateIndexReq.IndexSettings = new IndexSettings();
                iCreateIndexReq.IndexSettings.NumberOfReplicas = 10;

                //iCreateIndexReq.IndexSettings.Mappings = new List<RootObjectMapping>();
                //RootObjectMapping rootObjectMapping = new RootObjectMapping();
                //rootObjectMapping.AllFieldMapping()
                //iCreateIndexReq.IndexSettings.Mappings.
                //client.CreateIndex(iCreateIndexReq);
                //client.CreateIndex(indexName,s=>s.)
                var resCreate = client.CreateIndex(indexName, s => s.AddMapping<DocumentModel>(f => f.MapFromAttributes()).NumberOfReplicas(1).NumberOfShards(10));

                //client.CreateIndex(indexName, new IndexSettings());
                //client.create
            }

            if (operation.Equals("delete"))
            {
                //client.DeleteById(indexName, "documents", document.DocumentId);
                IDeleteByQueryRequest iDeleteByQueryRequest = new DeleteByQueryRequest();
                //IDeleteIndexRequest delReq = new DeleteIndexRequest(indexName);
                //client.DeleteIndex()
                //client.DeleteByQuery(new DeleteByQueryRequest())
                client.Delete<DocumentModel>(f => f.Id(document.DocumentId).Index(indexName).Refresh());
                //var response = this.Client.Delete<ElasticsearchProject>(f=>f.Id(newDocument.Id).Index(newIndex).Refresh());
            }
            else
            {
               //IIndexRequest<DocumentModel> indexRequest = IndexRequest<DocumentModel>();
               //client.Index(i)
               //client.Index(document, indexName, "documents", document.DocumentId);
               //IndexDescriptor indexDesc = IndexDescriptor;
               //IndexRequestParameters indexParameter = new IndexRequestParameters();
               // indexParameter.Replication(1);
                client.Index(document, i => i.Id(document.DocumentId).Index(indexName));
                //client.Index();
                //client.Index()
            }
        }
开发者ID:biantech,项目名称:ESSearchBoxSample,代码行数:52,代码来源:DocumentManagementController.cs

示例15: SelectAll

 public List<ad_network> SelectAll()
 {
     List<ad_network> list = new List<ad_network>();
     var connectionSettings = new ConnectionSettings(MainVariables.conElasticSearch);
     connectionSettings.SetDefaultIndex("ad_network");
     var elasticClient = new ElasticClient(connectionSettings);
     var searchResults = elasticClient.Search<ad_network>(s => s.Query(q => q.MatchAll()));
     list = searchResults.Documents.ToList();
     return list;
 }
开发者ID:azhard4int,项目名称:crawlers,代码行数:10,代码来源:ModelFbDetail.cs


注:本文中的Nest.ConnectionSettings.SetDefaultIndex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。