Esempio n. 1
0
        public static IServiceCollection AddElasticOptions(this IServiceCollection services, IConfigurationSection elasticConfigSection)
        {
            _elasticConfig = new ElasticConfig();
            elasticConfigSection.Bind(_elasticConfig);

            return(services.Configure <ElasticConfig>(elasticConfigSection));
        }
Esempio n. 2
0
 public ElasticConnection(IElasticConfig elasticConfig)
 {
     _elasticIndex = elasticConfig.IndexName;
     _node         = new Uri(elasticConfig.ElastisearchUrl);
     _settings     = new ConnectionSettings(_node)
                     .DefaultIndex(_elasticIndex);
     _client = new ElasticClient(_settings);
 }
Esempio n. 3
0
        /// <summary>构造函数</summary>
        public IndexerService(IElasticConfig elasticConfig, ISearchService searchService, IServerAppDataService appDataService)
        {
            this.Client    = elasticConfig.Client.As <ElasticClient>();
            this.IndexType = elasticConfig.MetadataType.As <TypeName>();
            var metadataDefinitionCollection = searchService.GetMetadataDefinitions();

            MetadataDefinitionCollection.Instance = new MetadataDefinitionCollection(metadataDefinitionCollection);
            this.RequiredMetadataDefinitions      = metadataDefinitionCollection.Where(e => e.Required && e.GroupCode != MetadataGroupCode.Inner).ToArray();
            this.AppDataService = appDataService;
        }
        public ElasticIndexService(
            IElasticConfig elasticConfig,
            IStorageService storageService,
            ILogger <ElasticIndexService> logger)
        {
            _elasticConfig = elasticConfig;
            client         = _elasticConfig.GetClient();

            _storageService = storageService;

            _logger = logger;

            CreateIndex(10000);
        }
Esempio n. 5
0
        public static void Initialize(IElasticConfig elasticConfig)
        {
            try
            {
                _elasticConfig = elasticConfig;

                var connectionPool = new SniffingConnectionPool(_elasticConfig.NodeUris.Select(p => new Uri(p)));
                ConnectionSettings = new ConnectionSettings(connectionPool).DefaultIndex(ElasticConfig.Indices.Main.Name());

                _elasticClient = new ElasticClient(ConnectionSettings);

                _initIndexTemplates();
            }
            catch (Exception ex)
            {
                // ToDo Logger
            }
        }
 public ElasticSearchService(IElasticConfig elasticConfig)
 {
     client = elasticConfig.GetClient();
 }
Esempio n. 7
0
 /// <summary>构造函数</summary>
 public SearchService(IElasticConfig elasticConfig, IMongoConfig mongoConfig, IMongoCollection <MetadataDefinition> accessor)
 {
     MdAccessor = accessor;
     _esAccess  = new ESAccess <Metadata>();
 }
Esempio n. 8
0
 /// <summary>构造函数</summary>
 public UserBehaviorService(IElasticConfig config)
 {
     this.Client    = config.Client.As <ElasticClient>();
     this.IndexType = config.UserBehaviorType.As <TypeName>();
     _esAccess      = new ESAccess <UserBehavior>();
 }