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

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

                List <Posts_Tags> sviPostoviTagovi = temp.getClanciByTag();
                foreach (var post_tags in sviPostoviTagovi)
                {
                    //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(directoryClanciTagovi);
            }
        }