Пример #1
0
        public string Get(string wanted)
        {
            LuceneEngine engine = new LuceneEngine();
            var          result = engine.Search("Title", wanted);

            return(JsonConvert.SerializeObject(result));
        }
Пример #2
0
        static void Main(string[] args)
        {
            #region Bad Way
            //var ws = new WeatherService();
            //var uc = new UnitConverter();
            //var cs = new CitySet();

            //var cityName = cs.GetCityFromZipCode("06300");
            //var city = ws.GetDataFromName(cityName);
            //var temperature = uc.FahrenheitToCelcius(city.Temperature);

            //Console.WriteLine("Temperature is : {0} in [ {1} ], at {2}. Coordinates : {3}, {4}", temperature, city.Name, city.Date, city.Latitude, city.Longtitude);
            //Console.ReadKey();
            #endregion

            #region Good Way

            //var wf = new WeatherFacade();
            //var c = wf.GetCityInformation("06300");
            //Console.WriteLine("Temperature is : {0} in [ {1} ], at {2}. Coordinates : {3}, {4}", c.Temperature, c.Name, c.Date, c.Latitude, c.Longtitude);
            //Console.ReadKey();
            #endregion

            var le = new LuceneEngine();
            var sw = new Stopwatch();
            sw.Start();
            var result = le.Search("FirstName", "Maria");
            sw.Stop();
            Console.WriteLine(sw.ElapsedMilliseconds);
            Console.ReadKey();
        }
Пример #3
0
        //без статик
        // все что понадобится и может быть связано с папкой  lucene
        private void btnSearch_Click(object sender, RoutedEventArgs e)
        {
            btnPlagCheck.IsEnabled = false;
            DownloadWork.IsEnabled = false;
            var engine = new DBEngine();

            try
            {
                if (engine.CheckWorks())
                {
                    txtAuth.Text = "";
                    txtDis.Text  = "";
                    txtName.Text = "";
                    txtDes.Text  = "";

                    LuceneEngine le = new LuceneEngine();
                    //var c = le.CountDocs();

                    int    number;//количество результатов
                    string field = "";
                    IEnumerable <FileToIndex> results;
                    if (txtboxSearch.Text.StartsWith("#"))
                    {
                        field   = "Hashtags";
                        results = le.Search(txtboxSearch.Text.Substring(1, txtboxSearch.Text.Length - 1),
                                            out number, field);
                    }
                    else
                    {
                        results = le.Search(txtboxSearch.Text,
                                            out number);
                    }
                    lstboxResult.Items.Clear();
                    foreach (var doc in results)
                    {
                        lstboxResult.Items.Add(doc.Id + " " + doc.Title);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Поиск не может быть проведен.\n" + ex, "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Пример #4
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);
        }
Пример #5
0
 public IEnumerable <ArchiveDocument> Execute(string val)
 {
     return(LuceneEngine.Search(val));
 }