當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。