Example #1
0
 private Task CreateGameHistoryMapping(Nest.IElasticClient client)
 {
     return(client.MapAsync <GameHistoryRecord>(m =>
                                                m.DynamicTemplates(templates => templates
                                                                   .DynamicTemplate("dates", t => t
                                                                                    .Match("CreatedOn")
                                                                                    .Mapping(ma => ma.Date(s => s))
                                                                                    )
                                                                   .DynamicTemplate("score", t =>
                                                                                    t.MatchMappingType("string")
                                                                                    .Mapping(ma => ma.Keyword(s => s.Index()))
                                                                                    )
                                                                   )
                                                ));
 }
        public static IElasticClient InitElasticClient(string indexName)
        {
            if (_elasticClient != null)
            {
                return(_elasticClient);
            }

            _logger.Info("InitElasticClient() - start");
            _elasticClient = new Nest.ElasticClient(
                new ConnectionSettings(
                    new SingleNodeConnectionPool(
                        new Uri(_elasticConnectionString)
                        )
                    )
                );
            _logger.Info("InitElasticClient() - done");


            return(_elasticClient);
        }
Example #3
0
 public override void Initialize(string name, NameValueCollection config)
 {
     base.Initialize(name, config);
     _elasticClient = Indexers.DefaultPublishedContentIndexer.InitElasticClient(_indexName);
 }