Exemple #1
0
 public string RelevanceEx(RelevanceFilter filter)
 {
     try
     {
         var vids = filter.vids.FormatStrToArray(SplitArray.LineArray);
         int vid = 0;
         if (int.TryParse(vids[0], out vid))
         {
             var video = ListCache.Instance.Dictionary[vid];
             return CreateSmarkPageList(LuceneNetUtil.RelevanceSearchEx(filter, SegmentKeyWord(video), filter.c + 1), filter, VideoParsUtils.FormateSearchVideoPars(filter), true);
         }
         return NoPlatForm();
     }
     catch (KeyNotFoundException)
     {
         return NoPlatForm();
     }
     catch (Exception ex)
     {
         return BoxUtils.FormatErrorMsg(ex);
     }
 }
Exemple #2
0
 /// <summary>
 /// 点播扩展关联推荐
 /// </summary>
 public static LuceneResultNode RelevanceSearchEx(RelevanceFilter filter, string query, int maxHit)
 {
     var fkey = new VideoNodeKey(filter.platform, 0, filter.auth);
     var rangenodes = new List<NumberRangeNode>();
     var containfilters = new List<ContainFilterNode>();
     var fbname = string.Empty;
     if (filter.forbidden)
     {
         filter.forbidden = VideoNodeKeyArray.Instance.Forbidden[fkey];
         if (filter.forbidden)
         {
             if (ForbiddenAreaCache.Instance.Items.ContainsKey(filter.fbcode))
             {
                 fbname = ForbiddenAreaCache.Instance.Items[filter.fbcode].ForbiddenAreaName;
             }
             else
             {
                 filter.forbidden = false;
             }
         }
     }
     if (filter.forbidden)
     {
         containfilters.Add(new ContainFilterNode() { FieldName = EpgIndexNode.ForbiddenCode, Text = fbname.ToLower() });
     }
     var pindx = VideoNodeKeyArray.Instance.Items[fkey].ToString();
     containfilters.Add(new ContainFilterNode() { FieldName = EpgIndexNode.PlatformIndex, Text = pindx });
     if (filter.bitratemin != 0 || filter.bitratemax != 0)
     {
         if (filter.bitratemax == 0) filter.bitratemax = int.MaxValue;
         rangenodes.Add(new NumberRangeNode() { FieldName = EpgIndexNode.BitrateRange, MinValue = filter.bitratemin, MaxValue = filter.bitratemax });
     }
     if (filter.hmin != 0 || filter.hmax != 0)
     {
         if (filter.hmax == 0) filter.hmax = int.MaxValue;
         rangenodes.Add(new NumberRangeNode() { FieldName = EpgIndexNode.HightRange, MinValue = filter.hmin, MaxValue = filter.hmax });
     }
     if (filter.wmin != 0 || filter.wmax != 0)
     {
         if (filter.wmax == 0) filter.wmax = int.MaxValue;
         rangenodes.Add(new NumberRangeNode() { FieldName = EpgIndexNode.WidthRange, MinValue = filter.wmin, MaxValue = filter.wmax });
     }
     if (filter.forbidvip == 1)
     {
         containfilters.Add(new ContainFilterNode() { FieldName = EpgIndexNode.VipFlag, Text = "0" });
     }
     if (filter.ver > 1 && filter.screen != "v")
     {
         containfilters.Add(new ContainFilterNode() { FieldName = EpgIndexNode.Screen, Text = "0" });
     }
     var node = new SearchNode();
     node.Key = filter.vids;
     node.Pindex = pindx;
     node.Queries = query;//Searcher.SegmentKeyWord(filter.k);
     node.Fields = EpgIndexNode.RelevanceFields;
     node.Occurs = EpgIndexNode.RelevanceOccurs;
     //node.SortFields = EpgIndexNode.SortFields;
     node.ContainFilters = containfilters;
     node.NumberRangeFiters = rangenodes;
     node.Start = 1;
     node.Limit = maxHit;
     node.IndexValue = EpgIndexNode.IndexValue;
     return Searcher.SearchMaxHitEx(EpgLuceneNet.Instance.IndexDic, node, maxHit);
 }
Exemple #3
0
 /// <summary>
 /// LuceneNet分页输出
 /// </summary>
 private static string CreateSmarkPageList(LuceneResultNode result, RelevanceFilter filter, VideoPars pars, bool isEx)
 {
     var xml = new XElement("vlist");
     var count = result.AllCount - 1;
     if (count < 0)
         count = 0;
     xml.Add(new XElement("count", count));
     //xml.Add(new XElement("page_count", PageUtils.PageCount(result.AllCount, filter.c)));
     //xml.Add(new XElement("countInPage", filter.c));
     //xml.Add(new XElement("page", filter.s));
     for (var i = 1; i < result.AllCount; i++)
     {
         xml.Add(pars.ResponseFun(ListCache.Instance.Dictionary[int.Parse(result.Result[i])], filter, isEx));
     }
     return xml.ToString(SaveOptions.DisableFormatting);
 }
Exemple #4
0
 /// <summary>
 /// 点播关联推荐
 /// </summary>
 public static LuceneResultNode RelevanceSearch(RelevanceFilter filter, string query, int maxHit)
 {
     var fkey = new VideoNodeKey(filter.platform, 0, filter.auth);
     var containfilters = new List<ContainFilterNode>();
     var fbname = string.Empty;
     if (filter.forbidden)
     {
         filter.forbidden = VideoNodeKeyArray.Instance.Forbidden[fkey];
         if (filter.forbidden)
         {
             if (ForbiddenAreaCache.Instance.Items.ContainsKey(filter.fbcode))
             {
                 fbname = ForbiddenAreaCache.Instance.Items[filter.fbcode].ForbiddenAreaName;
             }
             else
             {
                 filter.forbidden = false;
             }
         }
     }
     if (filter.forbidden)
     {
         containfilters.Add(new ContainFilterNode() { FieldName = EpgIndexNode.ForbiddenCode, Text = fbname.ToLower() });
     }
     var pindx = VideoNodeKeyArray.Instance.Items[fkey].ToString();
     containfilters.Add(new ContainFilterNode() { FieldName = EpgIndexNode.PlatformIndex, Text = pindx });
     if (filter.ver > 1 && filter.screen != "v")
     {
         containfilters.Add(new ContainFilterNode() { FieldName = EpgIndexNode.Screen, Text = "0" });
     }
     var node = new SearchNode();
     node.Key = filter.vids;
     node.Pindex = pindx;
     node.Queries = query;//Searcher.SegmentKeyWord(filter.k);
     node.Fields = EpgIndexNode.RelevanceFields;
     node.Occurs = EpgIndexNode.RelevanceOccurs;
     node.ContainFilters = containfilters;
     node.Start = 1;
     node.Limit = maxHit;
     node.IndexValue = EpgIndexNode.IndexValue;
     return Searcher.SearchMaxHit(EpgLuceneNet.Instance.IndexDic, node, maxHit);
 }