Ejemplo n.º 1
0
        public static Directory GetDirectoryPitanjaTagovi()
        {
            using (TriglavBL temp = new TriglavBL())
               {
               Directory directoryPitanjaTagovi = FSDirectory.Open(new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + "PitanjaTagovi"));
               Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_30);

               var writer = new IndexWriter(directoryPitanjaTagovi, analyzer, true, IndexWriter.MaxFieldLength.LIMITED);

               List<Posts_Tags> svaPitanjaTagovi = temp.getPitanjaByTaG();
               foreach (var post_tags in svaPitanjaTagovi)
               {
                   //Add & boost
                   var Posts_Tags = new Document();
                   Posts_Tags.Add(new Field("id", Convert.ToString(post_tags.id), Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS, Field.TermVector.NO));
                   Posts_Tags.Add(new Field("PostID", Convert.ToString(post_tags.PostID), Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS, Field.TermVector.NO));
                   Posts_Tags.Add(new Field("TagID", Convert.ToString(post_tags.TagID), Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS, Field.TermVector.NO));

                   writer.AddDocument(Posts_Tags);
               }

               writer.Optimize();
               writer.Dispose();
               return directoryPitanjaTagovi;
               }
        }