Examples of indexDictionary()


Examples of org.apache.lucene.search.spell.CustomSpellChecker.indexDictionary()

      fields = didyoumean.getDym_fields();
    }
    try {
      for (String fieldname : fields) {
        LuceneDictionary dict = new LuceneDictionary(sourceReader, fieldname);
        spellchecker.indexDictionary(dict);
      }
    } finally {
      if (sourceAccessor != null && sourceReader != null) {
        sourceAccessor.release(sourceReader, false);
      }
View Full Code Here

Examples of org.apache.lucene.search.spell.SpellChecker.indexDictionary()

        // 1. Create content spellIndex
        File spellDictionaryFile = new File(spellDictionaryPath);
        Directory contentSpellIndexDirectory = FSDirectory.open(new File(spellDictionaryPath + CONTENT_PATH));//true
        SpellChecker contentSpellChecker = new SpellChecker(contentSpellIndexDirectory);
        Dictionary contentDictionary = new LuceneDictionary(indexReader, OlatDocument.CONTENT_FIELD_NAME);
        contentSpellChecker.indexDictionary(contentDictionary);
        // 2. Create title spellIndex
        Directory titleSpellIndexDirectory = FSDirectory.open(new File(spellDictionaryPath + TITLE_PATH));//true
        SpellChecker titleSpellChecker = new SpellChecker(titleSpellIndexDirectory);
        Dictionary titleDictionary = new LuceneDictionary(indexReader, OlatDocument.TITLE_FIELD_NAME);
        titleSpellChecker.indexDictionary(titleDictionary);
View Full Code Here

Examples of org.apache.lucene.search.spell.SpellChecker.indexDictionary()

        contentSpellChecker.indexDictionary(contentDictionary);
        // 2. Create title spellIndex
        Directory titleSpellIndexDirectory = FSDirectory.open(new File(spellDictionaryPath + TITLE_PATH));//true
        SpellChecker titleSpellChecker = new SpellChecker(titleSpellIndexDirectory);
        Dictionary titleDictionary = new LuceneDictionary(indexReader, OlatDocument.TITLE_FIELD_NAME);
        titleSpellChecker.indexDictionary(titleDictionary);
        // 3. Create description spellIndex
        Directory descriptionSpellIndexDirectory = FSDirectory.open(new File(spellDictionaryPath + DESCRIPTION_PATH));//true
        SpellChecker descriptionSpellChecker = new SpellChecker(descriptionSpellIndexDirectory);
        Dictionary descriptionDictionary = new LuceneDictionary(indexReader, OlatDocument.DESCRIPTION_FIELD_NAME);
        descriptionSpellChecker.indexDictionary(descriptionDictionary);
View Full Code Here

Examples of org.apache.lucene.search.spell.SpellChecker.indexDictionary()

        titleSpellChecker.indexDictionary(titleDictionary);
        // 3. Create description spellIndex
        Directory descriptionSpellIndexDirectory = FSDirectory.open(new File(spellDictionaryPath + DESCRIPTION_PATH));//true
        SpellChecker descriptionSpellChecker = new SpellChecker(descriptionSpellIndexDirectory);
        Dictionary descriptionDictionary = new LuceneDictionary(indexReader, OlatDocument.DESCRIPTION_FIELD_NAME);
        descriptionSpellChecker.indexDictionary(descriptionDictionary);
        // 4. Create author spellIndex
        Directory authorSpellIndexDirectory = FSDirectory.open(new File(spellDictionaryPath + AUTHOR_PATH));//true
        SpellChecker authorSpellChecker = new SpellChecker(authorSpellIndexDirectory);
        Dictionary authorDictionary = new LuceneDictionary(indexReader, OlatDocument.AUTHOR_FIELD_NAME);
        authorSpellChecker.indexDictionary(authorDictionary);
View Full Code Here

Examples of org.apache.lucene.search.spell.SpellChecker.indexDictionary()

        descriptionSpellChecker.indexDictionary(descriptionDictionary);
        // 4. Create author spellIndex
        Directory authorSpellIndexDirectory = FSDirectory.open(new File(spellDictionaryPath + AUTHOR_PATH));//true
        SpellChecker authorSpellChecker = new SpellChecker(authorSpellIndexDirectory);
        Dictionary authorDictionary = new LuceneDictionary(indexReader, OlatDocument.AUTHOR_FIELD_NAME);
        authorSpellChecker.indexDictionary(authorDictionary);
       
        // Merge all part spell indexes (content,title etc.) to one common spell index
        Directory spellIndexDirectory = FSDirectory.open(spellDictionaryFile);//true
        IndexWriter merger = new IndexWriter(spellIndexDirectory, new StandardAnalyzer(Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.UNLIMITED);
        Directory[] directories = { contentSpellIndexDirectory, titleSpellIndexDirectory, descriptionSpellIndexDirectory, authorSpellIndexDirectory};
View Full Code Here

Examples of org.apache.lucene.search.spell.SpellChecker.indexDictionary()

        spellDir = FSDirectory.getDirectory(spellFile);
        reader = _getReader(id,false);
        Dictionary dictionary = new LuceneDictionary(reader,"contents");
     
        SpellChecker spellChecker = new SpellChecker(spellDir);
        spellChecker.indexDictionary(dictionary);
     
      }
      catch(IOException ioe) {
        throw new SearchException(ioe);
      }
View Full Code Here

Examples of org.apache.lucene.search.spell.SpellChecker.indexDictionary()

                new CacheLoader<String, SpellChecker>() {
                    @Override
                    public SpellChecker load(String field) throws Exception {
                        SpellChecker spellChecker = new SpellChecker(ramDirectoryCache.get(field));
                        IndexWriterConfig indexWriterConfig = new IndexWriterConfig(Version.LUCENE_44, new WhitespaceAnalyzer(Version.LUCENE_44));
                        spellChecker.indexDictionary(dictCache.getUnchecked(field), indexWriterConfig, false);
                        return spellChecker;
                    }
                }
        );
View Full Code Here

Examples of org.apache.lucene.search.spell.SpellChecker.indexDictionary()

        try {
            log.info("Generating spelling suggestion index ... ");
            indexReader = IndexReader.open(indexDirectory);
            checker = new SpellChecker(spellDirectory);
            //TODO below seems only to index "defs" , possible bug ?
            checker.indexDictionary(new LuceneDictionary(indexReader, "defs"), new IndexWriterConfig(Version.LUCENE_36, null), true);
            log.info("done");
        } catch (IOException e) {
            log.log(Level.SEVERE, "ERROR: Generating spelling: {0}", e);
        } finally {
            if (indexReader != null) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.