Exemple #1
0
        public string Get(string wanted)
        {
            LuceneEngine engine = new LuceneEngine();
            var          result = engine.Search("Title", wanted);

            return(JsonConvert.SerializeObject(result));
        }
        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();
        }
Exemple #3
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);
        }
        //без статик
        // все что понадобится и может быть связано с папкой  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);
            }
        }
        static void Main(string[] args)
        {
            List <string> PathSuffixList = new List <string>();
            List <Type>   typeList       = new List <Type>()
            {
                typeof(JD_Commodity_001)
            };
            int count = 0;

            foreach (Type type in typeList)
            {
                count++;
                PathSuffixList.Add(type.Name);
                LuceneEngine engine = new LuceneEngine(type);
                engine.Star();
                if (count == typeList.Count)
                {
                    engine.MergeIndex(PathSuffixList.ToArray());
                }
            }
        }
Exemple #6
0
        public object Execute()
        {
            Console.WriteLine("Services Loading...");

            AppSettingCache.Instance.Init();
            //CustomerCache.Instance.SerializeInit();
            //PlatFormCache.Instance.SerializeInit();

            LuceneEngine engine = new LuceneEngine();

            engine.Init();

            ////点播
            //if (bool.Parse(AppSettingCache.Instance["VodAct"]))
            //{
            //    BoxTypeCache.Instance.SerializeInit();
            //    RecommandCache.Instance.SerializeInit();
            //    ListCache.Instance.SerializeInit();
            //    TagCache.Instance.SerializeInit();
            //}

            ////直播
            //if (bool.Parse(AppSettingCache.Instance["LiveAct"]))
            //{
            //    ChannelLiveItemsCache.Instance.SerializeInit();
            //    LiveTypeCache.Instance.SerializeInit();
            //    LiveListCache.Instance.SerializeInit();
            //    LiveTypeDicCache.Instance.SerializeInit();
            //    LiveRecommandCache.Instance.SerializeInit();
            //}

            //后台接口
            if (bool.Parse(AppSettingCache.Instance["BackJobAct"]))
            {
                YesterdayListCache.Instance.SerializeInit();
            }

            return(null);
        }
Exemple #7
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);
        }
        public object Execute()
        {
            Console.WriteLine("Services Loading...");

            AppSettingCache.Instance.Init();
            //CustomerCache.Instance.SerializeInit();
            //PlatFormCache.Instance.SerializeInit();

            LuceneEngine engine = new LuceneEngine();
            engine.Init();

            ////点播
            //if (bool.Parse(AppSettingCache.Instance["VodAct"]))
            //{
            //    BoxTypeCache.Instance.SerializeInit();
            //    RecommandCache.Instance.SerializeInit();
            //    ListCache.Instance.SerializeInit();
            //    TagCache.Instance.SerializeInit();
            //}

            ////直播
            //if (bool.Parse(AppSettingCache.Instance["LiveAct"]))
            //{
            //    ChannelLiveItemsCache.Instance.SerializeInit();
            //    LiveTypeCache.Instance.SerializeInit();
            //    LiveListCache.Instance.SerializeInit();
            //    LiveTypeDicCache.Instance.SerializeInit();
            //    LiveRecommandCache.Instance.SerializeInit();
            //}

            //后台接口
            if (bool.Parse(AppSettingCache.Instance["BackJobAct"]))
            {
                YesterdayListCache.Instance.SerializeInit();
            }

            return null;
        }
Exemple #9
0
        public void ContainAnalyzerTest()
        {
            LuceneEngine engine = new LuceneEngine();

            engine.Init();
            //string text = "三国演义";
            //string text = "a|f|g|i|m";
            string         text = "NBA常规赛-快船vs凯尔特人";
            TextReader     tr   = new StringReader(text);
            PanGuTokenizer ct   = new PanGuTokenizer(tr);
            int            end  = 0;

            Lucene.Net.Analysis.Token t;
            string ss = string.Empty;

            while (end < text.Length)
            {
                t   = ct.Next();
                end = t.EndOffset();
                ss  = ss + t.TermText() + "/ ";
            }
            string xxx = ss;
        }
Exemple #10
0
        public void SpellTest()
        {
            LuceneEngine engine = new LuceneEngine();

            engine.Init();
            var firsts     = SpellUtils.GetCnSegment("NBA常规赛-快船vs凯尔特人");
            var spells     = SpellUtils.GetSpellSegment("战重警和");
            var segment    = new Segment();
            var collection = segment.DoSegment("国际足球100509K联赛釜山-大田");
            var list       = new List <string>();

            foreach (WordInfo word in collection)
            {
                if (word == null)
                {
                    continue;
                }
                list.Add(word.Word);
            }
            //var list = SpellUtils.GetSpellSegment("战警");
            string         sss  = "san国yan义";
            string         ssss = Synacast.LuceneNetSearcher.Searcher.Searcher.SegmentKeyWord(sss);
            string         text = "重庆";
            TextReader     tr   = new StringReader(text);
            PanGuTokenizer ct   = new PanGuTokenizer(tr);
            int            end  = 0;

            Lucene.Net.Analysis.Token t;
            string ss = string.Empty;

            while (end < text.Length)
            {
                t   = ct.Next();
                end = t.EndOffset();
                ss  = ss + t.TermText() + "/ ";
            }
        }
Exemple #11
0
 public void ContainAnalyzerTest()
 {
     LuceneEngine engine = new LuceneEngine();
     engine.Init();
     //string text = "三国演义";
     //string text = "a|f|g|i|m";
     string text = "NBA常规赛-快船vs凯尔特人";
     TextReader tr = new StringReader(text);
     PanGuTokenizer ct = new PanGuTokenizer(tr);
     int end = 0;
     Lucene.Net.Analysis.Token t;
     string ss = string.Empty;
     while (end < text.Length)
     {
         t = ct.Next();
         end = t.EndOffset();
         ss = ss + t.TermText() + "/ ";
     }
     string xxx = ss;
 }
Exemple #12
0
 public void SpellTest()
 {
     
     LuceneEngine engine = new LuceneEngine();
     engine.Init();
     var firsts = SpellUtils.GetCnSegment("NBA常规赛-快船vs凯尔特人");
     var spells = SpellUtils.GetSpellSegment("战重警和");
     var segment = new Segment();
     var collection = segment.DoSegment("国际足球100509K联赛釜山-大田");
     var list = new List<string>();
     foreach (WordInfo word in collection)
     {
         if (word == null)
             continue;
         list.Add(word.Word);
     }
     //var list = SpellUtils.GetSpellSegment("战警");
     string sss = "san国yan义";
     string ssss = Synacast.LuceneNetSearcher.Searcher.Searcher.SegmentKeyWord(sss);
     string text = "重庆";
     TextReader tr = new StringReader(text);
     PanGuTokenizer ct = new PanGuTokenizer(tr);
     int end = 0;
     Lucene.Net.Analysis.Token t;
     string ss = string.Empty;
     while (end < text.Length)
     {
         t = ct.Next();
         end = t.EndOffset();
         ss = ss + t.TermText() + "/ ";
     }
 }
Exemple #13
0
 public IEnumerable <ArchiveDocument> Execute(string val)
 {
     return(LuceneEngine.Search(val));
 }