示例#1
0
        private static void AddOutDoor(OutDoorIndexEntity OutDoor)
        {
            var document = new Document();

            var field = new Field("Title", OutDoor.Title, Field.Store.NO, Field.Index.ANALYZED);
            field.Boost = 2.5f;
            document.Add(field);

            field = new Field("Description", OutDoor.Description, Field.Store.NO, Field.Index.ANALYZED);
            field.Boost = 2.1f;
            document.Add(field);

            field = new Field("AreaAtt", OutDoor.AreaAtt, Field.Store.NO, Field.Index.ANALYZED);
            field.Boost = 0.8f;
            document.Add(field);

            field = new Field("CityName", OutDoor.CityName, Field.Store.NO, Field.Index.ANALYZED);
            field.Boost = 0.8f;
            document.Add(field);

            field = new Field("PCityName", OutDoor.PCityName, Field.Store.NO, Field.Index.ANALYZED);
            field.Boost = 0.8f;
            document.Add(field);

            field = new Field("MediaCateName", OutDoor.MediaCateName, Field.Store.NO, Field.Index.ANALYZED);
            field.Boost = 0.8f;
            document.Add(field);

            field = new Field("PMediaCateName", OutDoor.PMediaCateName, Field.Store.NO, Field.Index.ANALYZED);
            field.Boost = 0.8f;
            document.Add(field);

            field = new Field("FormatName", OutDoor.FormatName, Field.Store.NO, Field.Index.ANALYZED);
            field.Boost = 0.8f;
            document.Add(field);

            field = new Field("PeriodName", OutDoor.PeriodName, Field.Store.NO, Field.Index.ANALYZED);
            field.Boost = 0.8f;
            document.Add(field);

            field = new Field("OwnerCateName", OutDoor.OwnerCateName, Field.Store.NO, Field.Index.ANALYZED);
            field.Boost = 0.8f;
            document.Add(field);

            field = new Field("Price", OutDoor.Price.ToString(), Field.Store.NO, Field.Index.ANALYZED);
            field.Boost = 0.8f;
            document.Add(field);

            document.Add(new Field("MediaID", OutDoor.MediaID.ToString(CultureInfo.InvariantCulture), Field.Store.YES, Field.Index.NO));

            document.Add(new Field("Published", OutDoor.Published.Ticks.ToString(), Field.Store.NO, Field.Index.NOT_ANALYZED));
            document.Add(
                new Field("Hit", OutDoor.Hit.ToString(CultureInfo.InvariantCulture), Field.Store.NO, Field.Index.NOT_ANALYZED));

            string displayName = OutDoor.Title;

            document.Add(new Field("DisplayName", displayName.ToLower(CultureInfo.CurrentCulture), Field.Store.NO, Field.Index.NOT_ANALYZED));

            _indexWriter.AddDocument(document);
        }
示例#2
0
        protected internal virtual List<OutDoorIndexEntity> GetOutDoors(BaseEfUnitOfWork context, DateTime? lastIndexTime)
        {
            List<OutDoorIndexEntity> result = new List<OutDoorIndexEntity>();
            IEnumerable<OutDoor> OutDoors = context.Set<OutDoor>()
                .Include(x => x.Area)
                .Include(x => x.AreaAtt)
                .Include(x => x.PeriodCate)
                .Include(x => x.FormatCate).OrderBy(x => x.AddTime);

            if (lastIndexTime == null)
            {

            }
            else
            {
                OutDoors = OutDoors.Where(x => x.AddTime > lastIndexTime);

            }
            foreach (var x in OutDoors.ToList())
            {

                OutDoorIndexEntity item = new OutDoorIndexEntity()
                {
                    MediaID = x.MediaID,
                    CityName = x.Area.CateName,
                    PCityName = x.Area.CateName,
                    AreaAtt = String.Join(",", x.AreaAtt.Select(y => y.AttName)),
                    Description = x.Description,
                    FormatName = x.FormatCate.CateName,
                    Hit = x.Hit,
                    MediaCateName = x.OutDoorMediaCate.CateName,
                    PMediaCateName = x.OutDoorMediaCate.CateName,
                    OwnerCateName = x.OutDoorMediaCate.CateName,
                    PeriodName = x.PeriodCate.CateName,
                    Price = Convert.ToInt32(x.Price),
                    Published = x.AddTime,
                    Title = x.Name
                };
                result.Add(item);

            }
            return result;
        }