public IActionResult getOffField(STFilterRequestData _objReqData) { searchcricket sc = new searchcricket(); List <SearchResultFilterData> obj = new List <SearchResultFilterData>(); BoolQuery _objNestedBoolQuery = new BoolQuery(); if (_objReqData != null) { MatchDetail _objMatchDetail = _objReqData.MatchDetail; Moments _objMomentsData = _objReqData.Moments; if (_objMomentsData != null) { if (_objMomentsData.IsBigMoment || _objMomentsData.IsFunnyMoment || _objMomentsData.IsAudioPiece) { QueryContainer _objNestedBoolQueryFor2 = new QueryContainer(); _objNestedBoolQueryFor2 = sc.GetMatchDetailQueryST(_objNestedBoolQueryFor2, _objMatchDetail); _objNestedBoolQueryFor2 = sc.GetS2MomentDetailQueryForST(_objMatchDetail, _objNestedBoolQueryFor2, _objMomentsData); var result = EsClient.Search <SearchResultFilterData>(s => s.Index("cricket").Query(q => _objNestedBoolQueryFor2).Size(10000)); foreach (var hit in result.Hits) { obj.Add(new SearchResultFilterData { Description = hit.Source.Description.ToString(), MarkIn = hit.Source.MarkIn.ToString(), MarkOut = hit.Source.MarkOut.ToString(), ShotType = hit.Source.MarkOut.ToString(), DeliveryType = hit.Source.DeliveryType.ToString() }); } } } } return(Ok(new { results = obj })); }
public IActionResult postSegments(STFilterRequestData _objReqData) { try { List <ResponseResult> value = new List <ResponseResult>(); searchcricket sc = new searchcricket(); QueryContainer _objNestedBoolQuery = new QueryContainer(); // EsClient = oLayer.CreateConnection(); if (_objReqData != null) { MatchDetail _objMatchDetail = _objReqData.MatchDetail; dynamic _objS1Data = _objReqData.S1Data; Moments _objMomentsData = _objReqData.Moments; if (_objMatchDetail != null) { _objNestedBoolQuery = sc.GetMatchDetailQueryST(_objNestedBoolQuery, _objMatchDetail); } if (_objS1Data != null) { _objNestedBoolQuery = sc.getCricketPlayerDetails(_objS1Data, _objNestedBoolQuery); _objNestedBoolQuery = sc.GetCricketMatchSituationQueryST(_objNestedBoolQuery, _objS1Data); //_objSearchResults.ResultData = LSObject.SearchStoryTeller(_objNestedBoolQuery, _objMatchDetail); } if (_objMomentsData != null) { if (!string.IsNullOrEmpty(_objMomentsData.Entities) || _objMomentsData.IsBigMoment || _objMomentsData.IsFunnyMoment || _objMomentsData.IsAudioPiece) { QueryContainer _objNestedBoolQueryFor2 = new QueryContainer(); _objNestedBoolQueryFor2 = sc.GetMatchDetailQueryST(_objNestedBoolQueryFor2, _objMatchDetail); _objNestedBoolQueryFor2 = sc.GetS2MomentDetailQueryForST(_objMatchDetail, _objNestedBoolQueryFor2, _objMomentsData); // if (_objLstSearchQuery.Count > 3)///If the count is more than matchdetail query list (need to rethink) //{ // _objSearchResults2.ResultData = LuceneService.FetchSearchResultFilterData(_objNestedBoolQueryFor2, sportid, "s2"); //} } } } return(Ok(new { results = value })); } catch (Exception ex) { return(BadRequest(ex.Message.ToString())); } }
public IActionResult GetFilteredEntitiesBySport(SearchEntityRequestData _objReqData) { searchcricket sc = new searchcricket(); int _sportid = 1; string result = string.Empty; string searchtext = string.Empty; List <SearchQueryModel> _objLstSearchQuery = new List <SearchQueryModel>(); var responseResult = new List <FilteredEntityForCricket>(); SearchEntityRequestData _objEntityReqData; string jsonData = JsonConvert.SerializeObject(_objReqData); _objEntityReqData = JsonConvert.DeserializeObject <SearchEntityRequestData>(jsonData); if (_objEntityReqData != null) { EsClient = oLayer.CreateConnection(); Dictionary <string, string> _columns = sc.GetColumnForEntity(_objEntityReqData.EntityTypeId); _sportid = _objEntityReqData.SportId; searchtext = _objEntityReqData.EntityText.Trim().ToLower(); MatchDetail _objMatchDetail = _objEntityReqData.MatchDetails; _objMatchDetail.SeriesId = _objEntityReqData.EntityTypeId != 5 ? _objMatchDetail.SeriesId : string.Empty; _objMatchDetail.MatchId = _objEntityReqData.EntityTypeId != 9 ? _objMatchDetail.MatchId : string.Empty; if (_columns != null && _columns.Count > 0) { KeyValuePair <string, string> _column = _columns.FirstOrDefault(); //Following query is to search the entire match detail if (_columns.Count > 0) { { List <string> EntityIds = new List <string>(); List <string> EntityNames = new List <string>(); foreach (var col in _columns) { EntityIds.Add(col.Key); EntityNames.Add(col.Value); } QueryContainer _objNestedQuery = new QueryContainer(); QueryContainer _objNestedQueryRresult = new QueryContainer(); IEnumerable <FilteredEntityForCricket> _objFilteredEntityForCricket = new List <FilteredEntityForCricket>(); _objNestedQuery = sc.GetMatchDetailQueryST(_objNestedQuery, _objMatchDetail); _objNestedQuery = sc.GetPlayerDetailQueryForFilteredEntityBySport(_objNestedQuery, _objEntityReqData.playerDetails, _objMatchDetail.SportID);//GetCricketPlayerDetailQuery(_objEntityReqData.playerDetails, _objNestedBoolQuery); if (!string.IsNullOrEmpty(_objMatchDetail.MatchDate)) { string dlist = _objMatchDetail.MatchDate; if (dlist.Contains("-")) { string[] strNumbers = dlist.Split('-'); int start = int.Parse(DateTime.ParseExact(strNumbers[0], "dd/MM/yyyy", CultureInfo.InvariantCulture).ToString("yyyyMMdd")); int End = int.Parse(DateTime.ParseExact(strNumbers[1], "dd/MM/yyyy", CultureInfo.InvariantCulture).ToString("yyyyMMdd")); _objNestedQuery = sc.GetFilteredEntitiesBySport(_objMatchDetail, _objNestedQuery, "1", start, _columns, searchtext); } else { int date = int.Parse(DateTime.ParseExact(_objMatchDetail.MatchDate, "dd/MM/yyyy", CultureInfo.InvariantCulture).ToString("yyyyMMdd")); _objNestedQuery = sc.GetFilteredEntitiesBySport(_objMatchDetail, _objNestedQuery, "2", date, _columns, searchtext); } } //if (_objEntityReqData.EntityTypeId == 5) //{ // var s1 = _objFilteredEntityForCricket.Select(d => new { EntityId = d.GetType().GetProperty(EntityIds.ElementAt(1)).GetValue(d, null), EntityName = d.GetType().GetProperty(EntityNames.ElementAt(1)).GetValue(d, null), IsParentSeries = 1 }).Distinct().ToList(); // var s2 = _objFilteredEntityForCricket.Select(d => new { EntityId = d.GetType().GetProperty(EntityIds.ElementAt(0)).GetValue(d, null), EntityName = d.GetType().GetProperty(EntityNames.ElementAt(0)).GetValue(d, null), IsParentSeries = 0 }).Distinct().ToList(); // var s = s1.Union(s2).Where(r => r.EntityName.ToString() != "" && r.EntityName.ToString().ToLower().Contains(searchtext)).Distinct().OrderBy(r => r.EntityName); // //result = _objSerializer.Serialize(s); //} //if (_objEntityReqData.EntityTypeId == 3 || _objEntityReqData.EntityTypeId == 4) //{ // var s1 = _objFilteredEntityForCricket.Select(t => new { EntityId = t.Team1Id, EntityName = t.Team1 }).Distinct(); // var s2 = _objFilteredEntityForCricket.Select(t => new { EntityId = t.Team2Id, EntityName = t.Team2 }).Distinct(); // var s = s1.Union(s2).Where(r => r.EntityName.ToString() != "" && r.EntityName.ToLower().Contains(searchtext)).Distinct().OrderBy(r => r.EntityName); // //result = _objSerializer.Serialize(s); //} //else if (searchtext != "") { //sc.GetFilteredEntitiesBySportResult(_objNestedQuery, EntityIds.ElementAt(0), EntityNames.ElementAt(0),EsClient); //var s = _objFilteredEntityForCricket.Select(d => new { EntityId = d.GetType().GetProperty(EntityIds.ElementAt(0)).GetValue(d, null), EntityName = d.GetType().GetProperty(EntityNames.ElementAt(0)).GetValue(d, null) }).Distinct(); var Result = sc.GetFilteredEntitiesBySportResult(_objNestedQuery, EntityIds.ElementAt(0), EntityNames.ElementAt(0), EsClient, searchtext); //result = _objSerializer.Serialize(Result); responseResult = Result; } _objFilteredEntityForCricket = null; } } } } return(Ok(new { responseText = responseResult })); }
public IActionResult GetSearchResultsFilter(STFilterRequestData _objReqData) { ExtendedSearchResultFilterData _objSearchResults = new ExtendedSearchResultFilterData(); ExtendedSearchResultFilterData _objSearchResults2 = new ExtendedSearchResultFilterData(); ExtendedSearchResultFilterData _objResult = new ExtendedSearchResultFilterData(); searchcricket sc = new searchcricket(); _objResult.ResultData = new List <SearchResultFilterData>(); _objSearchResults2.ResultData = new List <SearchResultFilterData>(); _objSearchResults.ResultData = new List <SearchResultFilterData>(); _objResult.Master = new MasterDatas(); _objResult.Master.MasterData = new Dictionary <string, object>(); _objSearchResults.Master = new MasterDatas(); _objSearchResults.Master.MasterData = new Dictionary <string, object>(); QueryContainer _objNestedQuery = new QueryContainer(); QueryContainer _objCricketResult = new QueryContainer(); if (_objReqData != null) { MatchDetail _objMatchDetail = _objReqData.MatchDetail; int sportid = _objMatchDetail.SportID; dynamic _objS1Data = _objReqData.S1Data; MatchSituation _objMatchSituation = _objReqData.MatchSituation; Moments _objMomentsData = _objReqData.Moments; if (_objMatchDetail != null) { _objNestedQuery = sc.GetMatchDetailQueryST(_objNestedQuery, _objMatchDetail); } if (_objS1Data != null) { if ("CRICKET" == sc.getType(sportid)) { IEnumerable <SearchResultFilterData> _objSearchResultsFilterData = new List <SearchResultFilterData>(); //_objNestedQuery = sc.getCricketPlayerDetails( _objS1Data, _objNestedQuery); //_objNestedQuery = sc.GetCricketMatchSituationQueryST(_objNestedQuery, _objMatchSituation); //_objSearchResults.ResultData = LSObject.SearchStoryTeller(_objNestedBoolQuery, _objMatchDetail); if (!_objMatchDetail.IsAsset) { Cricket objCs = new Cricket(); EsClient = oLayer.CreateConnection(); //_objCricketResult = sc.GetMatchDetailQueryST(_objCricketResult, _objMatchDetail); _objCricketResult = sc.getCricketPlayerDetails(_objS1Data, _objNestedQuery); _objCricketResult = sc.GetCricketMatchSituationQueryST(_objNestedQuery, _objMatchSituation); CommonFunction cf = new CommonFunction(); GetSearchS1DataForCricket sqObj = new GetSearchS1DataForCricket(); //string value = sqObj.GetKeyValueForSport(sc.getType(sportid), "DropdwonKey"); QueryContainer queryShould = new QueryContainer(); QueryContainer queryAnd = new QueryContainer(); QueryContainer queryAnd_should = new QueryContainer(); //List<string> valueObj = sqObj.GetKeyValueForSportTemp(sc.getType(sportid), "PlayerDetails"); //string[] valuessObj = valueObj.ToList(); //for (int i = 0; i <= valueObj.Count-1; i++) //{ // string sType = valueObj[i].Split(",")[1]; // if (sType == "Boolean") { // if (Convert.ToBoolean(_objS1Data[valueObj[i].Split(":")[1].Split(",")[0]])) // { // QueryContainer query1 = new TermQuery { Field = valueObj[i].Split(",")[2], Value = "1" }; // queryShould |= query1; // } // } // if (sType == "string") { // if (Convert.ToString(_objS1Data[valueObj[i].Split(":")[1]]) != "") // { // string slist = Convert.ToString(_objS1Data[valueObj[i].Split(",")[0].Split(":")[1]]); // if (slist.Contains(",")) // { // string[] strArray = slist.Split(','); // foreach (string str in strArray) // { // QueryContainer query9 = new TermQuery { Field = valueObj[i].Split(",")[2], Value = str }; // queryShould |= query9; // } // } // else { // QueryContainer query10 = new TermQuery { Field = valueObj[i].Split(",")[2], Value = Convert.ToString(_objS1Data[valueObj[i].Split(",")[0].Split(":")[1]]) }; // queryAnd &= query10; // } // } // } // if (valueObj[i].Split(":")[0] == "OR") { // queryAnd_should &= queryShould; // } //} //queryAnd &= queryAnd_should; //string[] valuess = value.Split(","); //foreach (var items in valuess) //{ // var item = items.Split("::"); // string Type = _objS1Data[item[0]]; // string[] _objType = Type.Contains(",") ? _objType = Type.Split(",") : _objType = new string[] { Type }; // _objSearchResults.Master.MasterData = objCs.fetchDropdowns(_objNestedQuery, _objSearchResults.Master.MasterData, EsClient, "cricket", cf.GetColumnForEntity(Convert.ToInt16(item[1])), _objType); //} //if (!string.IsNullOrEmpty(_objMatchSituation.Innings)) //{ // List<FilteredEntityData> obj2 = new List<FilteredEntityData>(); // Dictionary<string, object> objInning = new Dictionary<string, object>(); // string[] _objReqInnings = _objMatchSituation.Innings.Contains(",") ? _objReqInnings = _objMatchSituation.Innings.Split(',') : _objReqInnings = new string[] { _objMatchSituation.Innings }; // for (int i = 1; i <= 2; i++) // { // obj2.Add(new FilteredEntityData // { // EntityId = i.ToString(), // EntityName = i.ToString(), // IsSelectedEntity = _objReqInnings.Contains(i.ToString()) ? 1 : 0 // }); // } // objInning.Add("Innings", obj2); // _objSearchResults.Master.MasterData = objInning; //} string[] _objReqInnings = _objMatchSituation.Innings.Contains(",") ? _objReqInnings = _objMatchSituation.Innings.Split(',') : _objReqInnings = new string[] { _objMatchSituation.Innings }; string ReqShotType = _objS1Data["ShotType"]; string ReqDeliveryType = _objS1Data["DeliveryType"]; string[] _objReqShotType = ReqShotType.Contains(",") ? _objReqShotType = ReqShotType.Split(",") : _objReqShotType = new string[] { _objS1Data["ShotType"] }; string[] _objReqDeliveryType = ReqDeliveryType.Contains(",") ? _objReqDeliveryType = ReqDeliveryType.Split(",") : _objReqDeliveryType = new string[] { _objS1Data["DeliveryType"] }; _objSearchResults.Master.MasterData = sc.parseDropdown(_objCricketResult, _objResult.Master.MasterData, EsClient, _objReqInnings, _objReqShotType, _objReqDeliveryType); _objResult.ResultData = sc.getSegementsData(EsClient, _objCricketResult); _objSearchResults.ResultData = _objResult.ResultData; } else { _objNestedQuery = sc.getCricketPlayerDetails(_objS1Data, _objNestedQuery); _objNestedQuery = sc.GetCricketMatchSituationQueryST(_objNestedQuery, _objMatchSituation); } if (_objMomentsData != null) { if (!string.IsNullOrEmpty(_objMomentsData.Entities) || _objMomentsData.IsBigMoment || _objMomentsData.IsFunnyMoment || _objMomentsData.IsAudioPiece) { QueryContainer _objNestedBoolQueryFor2 = new QueryContainer(); _objNestedBoolQueryFor2 = sc.GetMatchDetailQueryST(_objNestedBoolQueryFor2, _objMatchDetail); _objNestedBoolQueryFor2 = sc.GetS2MomentDetailQueryForST(_objMatchDetail, _objNestedBoolQueryFor2, _objMomentsData); _objSearchResults2.ResultData = sc.getSegementsData(EsClient, _objNestedBoolQueryFor2); } _objResult.ResultData = _objSearchResults.ResultData.Union(_objSearchResults2.ResultData); } } } } return(Ok(new { responseText = _objSearchResults })); }