Beispiel #1
0
        // POST api/search
        public void Post()
        {
            LuceneEngine engine      = new LuceneEngine();
            var          classifieds = Builder <Classifieds> .CreateListOfSize(100)
                                       .All()
                                       .With(c => c.Id       = Faker.RandomNumber.Next(1000000))
                                       .With(c => c.Title    = Faker.Lorem.Sentence(6))
                                       .With(c => c.Price    = Faker.RandomNumber.Next(1000000))
                                       .With(c => c.Region   = Faker.Lorem.Words(2).FirstOrDefault())
                                       .With(c => c.City     = Faker.Lorem.Words(2).FirstOrDefault())
                                       .With(c => c.CityArea = Faker.Lorem.Words(2).FirstOrDefault())
                                       .Build();

            engine.AddToIndex(classifieds);
        }
Beispiel #2
0
        public List <Data.Models.Article> Search(string searchKey)
        {
            try
            {
                LuceneEngine engine = new LuceneEngine();

                engine.AddToIndex(_dbContext.Set <Article.Blog.Data.Models.Article>().ToList());

                var result = engine.Search("Name", searchKey);

                if (result.Count > 0)
                {
                    return(result);
                }
            }
            catch (System.Exception ex)
            {
                _logger.Error($"Search Article : {ex}");
            }

            return(null);
        }
        protected void btnEkle_Click(object sender, EventArgs e)
        {
            engine.DeleteAllDocuments();

            List <Product> products = new List <Product>();

            products.Add(new Product()
            {
                Id = 1, Name = "Apple Iphone 6", Description = "Lorem ipsum"
            });
            products.Add(new Product()
            {
                Id = 2, Name = "MacBook Air"
            });
            products.Add(new Product()
            {
                Id = 3, Name = "Sony Xperia Z Ultra", Description = "dolor amet"
            });
            products.Add(new Product()
            {
                Id = 4, Name = "Samsung Ultra HD Tv"
            });
            products.Add(new Product()
            {
                Id = 5, Name = "Asus Zenphone 6"
            });
            products.Add(new Product()
            {
                Id = 6, Name = "Sony Xperia Z 3"
            });
            products.Add(new Product()
            {
                Id = 7, Name = "Sony Playstation 3"
            });

            engine.AddToIndex(products);
        }