public void Write(Hadith hadith)
        {
            if (hadith.Id <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(Hadith.Id));
            }

            var document = new Document();

            document.Boost = DocumentWeights.Weights["Hadith-" + hadith.CollectionCode];
            document.StoreAndIndex(hadith, x => x.Id);
            foreach (VerseRangeReference verseRangeReference in hadith.VerseRangeReferences)
            {
                string indexName = ExpressionExtensions.GetIndexName <Hadith, object>(x => x.VerseRangeReferences);
                document.StoreAndIndex(indexName, verseRangeReference.ToIndexValue());
            }
            document.AddSearchableText(hadith.ArabicText);
            document.AddSearchableText(hadith.EnglishText);
            document.StoreAndIndex(hadith, x => x.CollectionCode);
            document.StoreAndIndex(hadith, x => x.PrimaryReferenceCode);
            document.StoreAndIndex(hadith, x => x.PrimaryReferencePath);
            document.AddObject(hadith);

            IndexWriter indexWriter = IndexWriterProvider.GetIndexWriter();

            indexWriter.AddDocument(document);

            WriteHadithReferences(indexWriter, hadith);
            WriteVerseReferences(indexWriter, hadith);
        }
Exemple #2
0
        public void Write(Verse verse)
        {
            if (verse == null)
            {
                throw new ArgumentNullException(nameof(verse));
            }

            var document = new Document();

            document.Boost = DocumentWeights.Weights["Quran"];
            IEnumerable <string> searchableText = verse.VerseTexts
                                                  .Where(x => string.Compare(x.TranslatorCode, "Transliteration", true) != 0)
                                                  .Select(x => x.Text);

            document
            .StoreAndIndex(verse, x => x.Id)
            .StoreAndIndex(verse, x => x.ChapterNumber)
            .StoreAndIndex(verse, x => x.VerseNumber)
            .AddSearchableText(searchableText)
            .AddObject(verse);

            IndexWriter indexWriter = IndexWriterProvider.GetIndexWriter();

            indexWriter.AddDocument(document);
        }
        public void Write(HadithCollection collection)
        {
            var document = new Document();

            document.AddObject(collection);

            IndexWriter indexWriter = IndexWriterProvider.GetIndexWriter();

            indexWriter.AddDocument(document);
        }
Exemple #4
0
        public void Write(Dictionary dictionary)
        {
            if (dictionary == null)
            {
                throw new ArgumentNullException(nameof(dictionary));
            }

            var document = new Document();

            document.AddObject(dictionary);

            IndexWriter indexWriter = IndexWriterProvider.GetIndexWriter();

            indexWriter.AddDocument(document);
        }
        public void Write(Commentator commentator)
        {
            if (commentator == null)
            {
                throw new ArgumentNullException(nameof(commentator));
            }

            var document = new Document();

            document.AddObject(commentator);

            IndexWriter indexWriter = IndexWriterProvider.GetIndexWriter();

            indexWriter.AddDocument(document);
        }
Exemple #6
0
        public void Migrate()
        {
            Directory.Delete(Settings.DataPath, true);
            Directory.CreateDirectory(Settings.DataPath);

            DictionariesMigrator.Migrate();
            CorpusMigrator.Migrate();
            QuranMigrator.Migrate();
            CommentaryMigrator.Migrate();
            HadithMigrator.Migrate();

            IndexWriter indexWriter = IndexWriterProvider.GetIndexWriter();

            indexWriter.Commit();
            indexWriter.Optimize(doWait: true);
        }
Exemple #7
0
        public void Write(Models.DictionaryEntry entry)
        {
            if (entry == null)
            {
                throw new ArgumentNullException(nameof(entry));
            }

            string indexValue = ArabicWordIndexer.GetIndexForArabic(entry.Word);
            var    document   = new Document();

            document.AddObject(entry);
            document.StoreAndIndex(entry, x => x.DictionaryCode);
            document.StoreAndIndex(DictionaryEntryRepository.RootWordsIndexName, indexValue);

            IndexWriter indexWriter = IndexWriterProvider.GetIndexWriter();

            indexWriter.AddDocument(document);
        }
        public void Write(VerseAnalysis verseAnalysis)
        {
            IEnumerable <string> roots = verseAnalysis.Words
                                         .SelectMany(x => x.WordParts)
                                         .Where(x => !string.IsNullOrWhiteSpace(x.Root))
                                         .Select(x => x.Root)
                                         .Distinct()
                                         .Select(ArabicWordIndexer.GetIndexForArabic);

            var document = new Document();

            document.StoreAndIndex(verseAnalysis, x => x.ChapterNumber);
            document.StoreAndIndex(verseAnalysis, x => x.VerseNumber);
            document.IndexArray(VerseAnalysisRepository.RootWordsIndexName, roots);
            document.AddObject(verseAnalysis);

            IndexWriter indexWriter = IndexWriterProvider.GetIndexWriter();

            indexWriter.AddDocument(document);
        }
        public void Write(Commentary commentary)
        {
            if (commentary == null)
            {
                throw new ArgumentNullException(nameof(commentary));
            }

            var document = new Document();

            document.Boost = DocumentWeights.Weights["Commentary-" + commentary.CommentatorCode];
            document.StoreAndIndex(commentary, x => x.CommentatorCode);
            document.StoreAndIndex(commentary, x => x.ChapterNumber);
            document.StoreAndIndex(commentary, x => x.FirstVerseNumber);
            document.StoreAndIndex(commentary, x => x.LastVerseNumber);
            document.AddSearchableText(commentary.Text.Select(x => x.Text));
            document.AddObject(commentary);

            IndexWriter indexWriter = IndexWriterProvider.GetIndexWriter();

            indexWriter.AddDocument(document);
        }