예제 #1
0
        public IEnumerable <DictionaryEntry> Get(string word)
        {
            string indexValue = ArabicWordIndexer.GetIndexForArabic(word);
            var    query      = new BooleanQuery(disableCoord: true);

            query
            .FilterByType <DictionaryEntry>()
            .AddPhraseQuery(RootWordsIndexName, indexValue, Occur.MUST);

            IndexSearcher searcher = IndexSearcherProvider.GetIndexSearcher();
            TopDocs       docs     = searcher.Search(query, 7000);
            IEnumerable <DictionaryEntry> results = docs.ScoreDocs
                                                    .Select(x => searcher.Doc(x.Doc))
                                                    .Select(x => x.GetObject <DictionaryEntry>());

            return(results);
        }
예제 #2
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);
        }
예제 #3
0
        public IEnumerable <VerseAnalysis> GetForRoot(string root)
        {
            string rootIndex = ArabicWordIndexer.GetIndexForArabic(root);
            var    query     = new BooleanQuery(disableCoord: true);

            query
            .FilterByType <VerseAnalysis>()
            .AddPhraseQuery(RootWordsIndexName, rootIndex, Occur.MUST);

            IndexSearcher indexSearcher = IndexSearcherProvider.GetIndexSearcher();
            TopDocs       topDocs       = indexSearcher.Search(query, 9999);

            IEnumerable <VerseAnalysis> result = topDocs.ScoreDocs
                                                 .Select(x => indexSearcher.Doc(x.Doc))
                                                 .Select(x => x.GetObject <VerseAnalysis>());

            return(result);
        }