Example #1
0
        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 }));
        }
Example #2
0
        public IActionResult getDeliveryTypeOnChange(STFilterRequestData _objReqData)
        {
            try
            {
                //List<QueryContainer> myDynamicMustQuery = new List<QueryContainer>();
                //var boolMustQuery = new BoolQuery();
                List <ddlValue>     obj      = new List <ddlValue>();
                HttpResponseMessage response = null;
                EsClient = oLayer.CreateConnection();
                List <ResponseResult> value = new List <ResponseResult>();
                searchcricket         sc    = new searchcricket();
                QueryContainer        _objNestedBoolQuery = new QueryContainer();
                if (_objReqData != null)
                {
                    MatchDetail _objMatchDetail = _objReqData.MatchDetail;
                    dynamic     _objS1Data      = _objReqData.S1Data;
                    _objNestedBoolQuery = sc.getCricketPlayerDetails(_objMatchDetail, _objNestedBoolQuery);
                }

                //QueryContainer q1 = new TermQuery { Field = "isTagged", Value = "1" };
                //QueryContainer q2 = new TermQuery { Field = "isAsset", Value = "0" };
                //QueryContainer q3 = new TermQuery { Field = "shotTypeId", Value = shotTypeId };

                //var q = new QueryContainer();
                //q &= q2;
                //q &= q1;
                //q &= q3;

                //myDynamicMustQuery.Add(q1);
                //myDynamicMustQuery.Add(q2);
                //myDynamicMustQuery.Add(q3);
                //boolMustQuery.Must = myDynamicMustQuery;

                var result = EsClient.Search <SearchCricketData>(a => a.Index("cricket").Size(0).Query(qs => _objNestedBoolQuery)
                                                                 .Aggregations(a1 => a1.Terms("my_terms_agg", t => t.Script(t1 => t1.Source("doc['deliveryType.keyword'].value + '|' + doc['deliveryTypeId.keyword'].value")).Size(802407))
                                                                               )
                                                                 );

                var agg = result.Aggregations.Terms("my_terms_agg").Buckets;


                foreach (var items in agg)
                {
                    obj.Add(new ddlValue
                    {
                        Id  = items.Key.ToString().Split("|")[1],
                        Key = items.Key.ToString().Split("|")[0]
                    });
                }
                return(Ok(new { results = obj }));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.ToString()));
            }
        }
        public IActionResult GetSearchResultsFilterTemp(STFilterRequestData _objReqData)
        {
            try
            {
                Cricket         objCS       = new Cricket();
                GetMatchDetails objMatchDet = new GetMatchDetails();
                EsClient_obj = oLayer.CreateConnection();
                ExtendedSearchResultFilterData _objSearchResults  = new ExtendedSearchResultFilterData();
                ExtendedSearchResultFilterData _objSearchResults2 = new ExtendedSearchResultFilterData();
                ExtendedSearchResultFilterData _objResult         = new ExtendedSearchResultFilterData();

                _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();
                if (_objReqData != null)
                {
                    MatchDetail    _objMatchDetail    = _objReqData.MatchDetail;
                    dynamic        _objS1Data         = _objReqData.S1Data;
                    MatchSituation _objMatchSituation = _objReqData.MatchSituation;
                    Moments        _objMomentsData    = _objReqData.Moments;
                    string         value     = sqObj.GetKeyValueForSport(sc.getType(_objMatchDetail.SportID), "DropdwonKey");
                    List <string>  valueObj  = sqObj.GetKeyValueForSportTemp(sc.getType(_objMatchDetail.SportID).ToLower(), "PlayerDetails");
                    string         SportName = sc.getType(_objMatchDetail.SportID);
                    if (_objS1Data != null)
                    {
                        _objNestedQuery   = objMatchDet.getDetailsAsPerSport(_objS1Data, _objNestedQuery, _objMatchDetail, _objMatchSituation, valueObj, _objMatchDetail.SportID);
                        _objSearchResults = objCf.searchStoryTeller(_objMatchDetail, _objNestedQuery, _objS1Data, _objResult.Master.MasterData, _objResult.ResultData, value, SportName.ToLower());
                    }
                    if (_objMomentsData != null)
                    {
                        QueryContainer objMoment = new QueryContainer();
                        objMoment = objCf.getMomentDetailsQueryST(_objMatchDetail, objMoment, _objMomentsData);
                        _objSearchResults2.ResultData = objCS.returnSportResult(EsClient_obj, objMoment, SportName);
                    }
                    _objResult.ResultData = _objSearchResults.ResultData.Union(_objSearchResults2.ResultData);
                    _objResult.Master     = _objSearchResults.Master;

                    if (_objMatchDetail.SportID == 1)
                    {
                        string[] _objReqInnings = _objMatchSituation.Innings.Contains(",") ? _objReqInnings = _objMatchSituation.Innings.Split(',') : _objReqInnings = new string[] { _objMatchSituation.Innings };
                        var      innings        = objCS.fetchDropDownForMatch(_objResult.Master.MasterData, _objReqInnings);
                        //_objResult.Master.MasterData.Add("Innings", innings);
                    }
                }
                return(Ok(new { responseText = _objResult }));
            }
            catch (Exception ex) {
                return(BadRequest());
            }
        }
 public IActionResult GetSearchResultsFilterTemp(STFilterRequestData _objReqData)
 {
     try
     {
         if (_objReqData != null)
         {
             _objResult = _sObj.GetSearchResultsFilter(_objReqData);
         }
         return(Ok(new { responseText = _objResult }));
     }
     catch (Exception ex)
     {
         return(BadRequest());
     }
 }
Example #5
0
        public IActionResult getSegments(STFilterRequestData _objReqData)
        {
            try
            {
                EsClient = oLayer.CreateConnection();
                List <SearchResultFilterData> obj = new List <SearchResultFilterData>();
                // var items="";
                STFilterRequestData objReqData      = new STFilterRequestData();
                searchcricket       sc              = new searchcricket();
                QueryContainer      _objNestedQuery = new QueryContainer();
                if (_objReqData != null)
                {
                    MatchDetail _objMatchDetail = _objReqData.MatchDetail;
                    dynamic     _objS1Data      = _objReqData.S1Data;
                    //Moments _objMomentsData = _objReqData.Moments;
                    if (_objMatchDetail != null)
                    {
                        //_objNestedBoolQuery = sc.GetMatchDetailQueryST(_objNestedBoolQuery, _objS1Data);
                        //System.Web.Script.Serialization.JavaScriptSerializer _objSerializer = new System.Web.Script.Serialization.JavaScriptSerializer();
                        string  jsonData = JsonConvert.SerializeObject(_objS1Data);
                        dynamic data     = JsonConvert.DeserializeObject(jsonData);
                        //SearchCricketData empObj = JsonConvert.DeserializeObject<SearchCricketData>(jsonData);
                        _objNestedQuery = sc.getCricketPlayerDetails(data, _objNestedQuery);
                        var result = EsClient.Search <SearchCricketData>(s => s.Index("cricket").Query(q => _objNestedQuery).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 }));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message.ToString()));
            }
        }
Example #6
0
        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()));
            }
        }
Example #7
0
        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 }));
        }
Example #8
0
        public IActionResult getShotTypeOnChange(STFilterRequestData _objReqData)
        {
            try
            {
                List <ResponseResult> value = new List <ResponseResult>();
                searchcricket         sc    = new searchcricket();
                QueryContainer        _objNestedBoolQuery = new QueryContainer();
                if (_objReqData != null)
                {
                    MatchDetail _objMatchDetail = _objReqData.MatchDetail;
                    dynamic     _objS1Data      = _objReqData.S1Data;
                    _objNestedBoolQuery = sc.getCricketPlayerDetails(_objMatchDetail, _objNestedBoolQuery);
                }
                //List<QueryContainer> myDynamicMustQuery = new List<QueryContainer>();
                //List<QueryContainer> myDynamicShouldQuery = new List<QueryContainer>();
                //var boolMustQuery = new BoolQuery();
                List <ddlValue>     obj      = new List <ddlValue>();
                HttpResponseMessage response = null;
                EsClient = oLayer.CreateConnection();
                //QueryContainer q1 = new TermQuery { Field = "isTagged", Value = "1" };
                //QueryContainer q2 = new TermQuery { Field = "isAsset", Value = "0" };

                //QueryContainer q3 = new TermQuery { Field = "isFour", Value = "1" };
                //QueryContainer q4 = new TermQuery { Field = "isSix", Value = "1" };
                //QueryContainer q5 = new TermQuery { Field = "isWicket", Value = "1" };
                //QueryContainer q6 = new TermQuery { Field = "isAppeal", Value = "1" };
                //QueryContainer q7 = new TermQuery { Field = "isDropped", Value = "1" };
                //QueryContainer q8 = new TermQuery { Field = "isMisField", Value = "1" };


                //QueryContainer q12 = new TermQuery { Field = "deliveryTypeId", Value = deliveryTypeId };
                //QueryContainer q9 = new TermQuery { Field = "clearId.keyword", Value = "HDP000015411--20160224094449152--CS--1014" };
                ////var q = new QueryContainer();
                ////q &= q2;
                ////q &= q1;
                ////q &= q3;

                //myDynamicMustQuery.Add(q1);
                //myDynamicMustQuery.Add(q2);
                //myDynamicMustQuery.Add(q9);
                //QueryContainer qs= q3 |= q4|=q5 |=q6|=q7|=q8;
                //myDynamicShouldQuery.Add(q4);
                //myDynamicShouldQuery.Add(q5);
                //myDynamicShouldQuery.Add(q6);
                //myDynamicShouldQuery.Add(q7);
                //myDynamicShouldQuery.Add(q8);


                //QueryContainer qr = q1 &= q2 &= q9 &= q12;//&= qs;
                //boolMustQuery.Should = myDynamicShouldQuery;
                var result = EsClient.Search <SearchCricketData>(a => a.Index("cricket").Size(0).Query(s => _objNestedBoolQuery)
                                                                 .Aggregations(a1 => a1.Terms("my_terms_agg", t => t.Script(t1 => t1.Source("doc['shotType.keyword'].value + '|' + doc['shotTypeId.keyword'].value")).Size(802407))
                                                                               )
                                                                 );
                var agg = result.Aggregations.Terms("my_terms_agg").Buckets;
                foreach (var items in agg)
                {
                    obj.Add(new ddlValue
                    {
                        Id  = items.Key.ToString().Split("|")[1],
                        Key = items.Key.ToString().Split("|")[0]
                    });
                }
                return(Ok(new { results = obj }));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.ToString()));
            }
        }