Exemplo n.º 1
0
        protected override IResponse CreateIndex()
        {
            var indexDescriptor = new CreateIndexDescriptor(IndexName).Mappings(
                ms => ms.Map <City>(m => m.AutoMap().Properties(ps =>
                                                                ps.Nested <District>(n => n
                                                                                     .Name(nn => nn.District)
                                                                                     .AutoMap()))));

            return(ElasticSearchClient.GetClient().CreateIndex(indexDescriptor));
        }
Exemplo n.º 2
0
        public override IEnumerable <City> Search(string query)
        {
            var results = ElasticSearchClient.GetClient().Search <City>(c => c.From(0).Size(10).Query(q => q.Prefix(p => p.Name, query) || q.Term("district.name", query)));

            return(results.Documents.OrderBy(d => d.Name));
        }
Exemplo n.º 3
0
 public CitiesService(ElasticSearchClient elasticSearchClient, string indexName) : base(elasticSearchClient, indexName)
 {
 }
Exemplo n.º 4
0
 public ElasticSearchService(ElasticSearchClient elasticSearchClient, string indexName)
 {
     ElasticSearchClient = elasticSearchClient;
     IndexName           = indexName;
 }