public IEnumerable <T> GetMany <T>(string _DefaultIndex, IEnumerable <string> ids, string[] fields) where T : class { //var re = client.GetMany<QuangCao>(ids, _DefaultIndex); //return re; var m = new MultiGetRequest(_DefaultIndex); var lst_get = new List <MultiGetOperation <T> >(); foreach (var item in ids) { lst_get.Add(new MultiGetOperation <T>(item)); } m.Documents = lst_get; m.SourceIncludes = fields; var mre = client.MultiGet(m); var lst_quang_cao = new List <T>(); foreach (var id in ids) { var quang_cao = mre.Source <T>(id); if (quang_cao != null) { Type t = quang_cao.GetType(); PropertyInfo piShared = t.GetProperty("id"); piShared.SetValue(quang_cao, id); lst_quang_cao.Add(quang_cao); } } return(lst_quang_cao); }
public IEnumerable <QuangCao> GetMany(IEnumerable <string> ids, string[] fields) { var m = new MultiGetRequest(_DefaultIndex); var lst_get = new List <MultiGetOperation <QuangCao> >(); foreach (var item in ids) { lst_get.Add(new MultiGetOperation <QuangCao>(item)); } m.Documents = lst_get; m.SourceIncludes = fields; var mre = client.MultiGet(m); var lst_quang_cao = new List <QuangCao>(); foreach (var id in ids) { var quang_cao = mre.Source <QuangCao>(id); if (quang_cao != null) { quang_cao.id = id; lst_quang_cao.Add(quang_cao); } } return(lst_quang_cao); }
public IEnumerable <QuangCao> GetMany(IEnumerable <string> ids, IEnumerable <TuKhoa> lst_tukhoa, string[] fields) { var m = new MultiGetRequest(_DefaultIndex); var lst_get = new List <MultiGetOperation <QuangCao> >(); foreach (var item in ids) { lst_get.Add(new MultiGetOperation <QuangCao>(item)); } m.Documents = lst_get; m.SourceIncludes = fields; var mre = client.MultiGet(m); var lst_quang_cao = new List <QuangCao>(); var ids_tukhoa = lst_tukhoa.Select(x => x.id); foreach (var id in ids) { var quang_cao = mre.Source <QuangCao>(id); if (quang_cao != null) { quang_cao.ids_tu_khoa = quang_cao.ids_tu_khoa != null?quang_cao.ids_tu_khoa.Where(x => ids_tukhoa.Contains(x)).ToList() : new List <string>(); //nếu từ khóa có url cuối thì lấy để thay thế cho url của quảng cáo var tk = lst_tukhoa.FirstOrDefault(x => quang_cao.ids_tu_khoa.Contains(x.id)); if (tk != null && !string.IsNullOrEmpty(tk.url_cuoi)) { quang_cao.link_dich = tk.url_cuoi; } quang_cao.id = id; lst_quang_cao.Add(quang_cao); } } return(lst_quang_cao); }
public MultiGetRequestTests() { var request = new MultiGetRequest { GetOperations = new List <IMultiGetOperation> { { new MultiGetOperation <ElasticsearchProject>(12) { Index = "some-other-index" } }, { new MultiGetOperation <ElasticsearchProject>("composite-id") { Fields = new [] { Property.Path <ElasticsearchProject>(p => p.Name) }, Routing = "routing-value", } } } }; var response = this._client.MultiGet(request); this._status = response.ConnectionStatus; }
public MultiGetRequestTests() { var request = new MultiGetRequest { GetOperations = new List<IMultiGetOperation> { { new MultiGetOperation<ElasticsearchProject>(12) { Index = "some-other-index"}}, { new MultiGetOperation<ElasticsearchProject>("composite-id") { Fields = new [] { Property.Path<ElasticsearchProject>(p=>p.Name) }, Routing = "routing-value", } } } }; var response = this._client.MultiGet(request); this._status = response.ConnectionStatus; }