Examples of LuceneDictionary


Examples of org.apache.lucene.search.spell.LuceneDictionary

        indexReader = IndexReader.open(indexDir);
        // 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);
        // 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);
       
        // 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);
View Full Code Here

Examples of org.apache.lucene.search.spell.LuceneDictionary

                              {
                                 IndexReader reader = handler.getIndexReader();
                                 try
                                 {
                                    long time = System.currentTimeMillis();
                                    Dictionary dict = new LuceneDictionary(reader, FieldNames.FULLTEXT);
                                    LOG.debug("Starting spell checker index refresh");
                                    spellChecker.indexDictionary(dict);
                                    time = System.currentTimeMillis() - time;
                                    time = time / 1000;
                                    LOG.info("Spell checker index refreshed in: " + new Long(time) + " s.");
View Full Code Here

Examples of org.apache.lucene.search.spell.LuceneDictionary

    } else {
      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.LuceneDictionary

    } else {
      fields = dym_fields;
    }
    try {
      for (String fieldname : fields) {
        LuceneDictionary dict = new LuceneDictionary(sourceReader, fieldname);
        spellchecker.indexDictionary(dict);
      }
    } finally {
      sourceReader.close();
    }
View Full Code Here

Examples of org.apache.lucene.search.spell.LuceneDictionary

    LuceneIndexLocation autocompleteLocation = this.autocompleter.getAutocompleteLocation();
    String autocompletefield = this.autocompleter.getAutocompletefield();

    IndexAccessor sia = source.getAccessor();
    IndexReader sourceReader = sia.getReader(false);
    LuceneDictionary dict = new LuceneDictionary(sourceReader, autocompletefield);
    IndexAccessor aia = autocompleteLocation.getAccessor();
    // IndexReader reader = aia.getReader(false);
    IndexWriter writer = aia.getWriter();

    try {
      writer.setMergeFactor(300);
      writer.setMaxBufferedDocs(150);
      // go through every word, storing the original word (incl. n-grams)
      // and the number of times it occurs
      // CREATE WORD LIST FROM SOURCE INDEX
      Map<String, Integer> wordsMap = new HashMap<String, Integer>();
      Iterator<String> iter = (Iterator<String>) dict.getWordsIterator();
      while (iter.hasNext()) {
        String word = iter.next();
        int len = word.length();
        if (len < 3) {
          continue; // too short we bail but "too long" is fine...
View Full Code Here

Examples of org.apache.lucene.search.spell.LuceneDictionary

    UseCase ucReIndex = MonitorFactory.startUseCase("reIndex()");
    // build a dictionary (from the spell package)
    log.debug("Starting to reindex autocomplete index.");
    IndexAccessor sia = this.source.getAccessor();
    IndexReader sourceReader = sia.getReader(false);
    LuceneDictionary dict = new LuceneDictionary(sourceReader, this.autocompletefield);
    IndexAccessor aia = this.autocompleteLocation.getAccessor();
    // IndexReader reader = aia.getReader(false);
    IndexWriter writer = aia.getWriter();

    try {
      writer.setMergeFactor(300);
      writer.setMaxBufferedDocs(150);
      // go through every word, storing the original word (incl. n-grams)
      // and the number of times it occurs
      // CREATE WORD LIST FROM SOURCE INDEX
      Map<String, Integer> wordsMap = new HashMap<String, Integer>();
      Iterator<String> iter = (Iterator<String>) dict.getWordsIterator();
      while (iter.hasNext()) {
        String word = iter.next();
        int len = word.length();
        if (len < 3) {
          continue; // too short we bail but "too long" is fine...
View Full Code Here

Examples of org.apache.lucene.search.spell.LuceneDictionary

                        {
                           IndexReader reader = handler.getIndexReader();
                           try
                           {
                              long time = System.currentTimeMillis();
                              Dictionary dict = new LuceneDictionary(reader, FieldNames.FULLTEXT);
                              log.debug("Starting spell checker index refresh");
                              spellChecker.indexDictionary(dict);
                              time = System.currentTimeMillis() - time;
                              time = time / 1000;
                              log.info("Spell checker index refreshed in: " + new Long(time) + " s.");
View Full Code Here

Examples of org.apache.lucene.search.spell.LuceneDictionary

                              {
                                 IndexReader reader = handler.getIndexReader();
                                 try
                                 {
                                    long time = System.currentTimeMillis();
                                    Dictionary dict = new LuceneDictionary(reader, FieldNames.FULLTEXT);
                                    log.debug("Starting spell checker index refresh");
                                    spellChecker.indexDictionary(dict);
                                    time = System.currentTimeMillis() - time;
                                    time = time / 1000;
                                    log.info("Spell checker index refreshed in: " + new Long(time) + " s.");
View Full Code Here

Examples of org.apache.lucene.search.spell.LuceneDictionary

                                                    if (site != null) {
                                                        fullTextName.append("-").append(site);
                                                    }
                                                    // add language independend
                                                    // fulltext values first
                                                    spellChecker.indexDictionary(new LuceneDictionary(reader,
                                                            fullTextName.toString()), 300, 10, site, language);

                                                    // add language dependend
                                                    // fulltext values
                                                    if (language != null) {
                                                        fullTextName.append("-").append(language);
                                                    }
                                                    spellChecker.indexDictionary(new LuceneDictionary(reader,
                                                            fullTextName.toString()), 300, 10, site, language);
                                                }
                                            }
                                            time = System.currentTimeMillis() - time;
                                            time = time / 1000;
View Full Code Here

Examples of org.apache.lucene.search.spell.LuceneDictionary

                              {
                                 IndexReader reader = handler.getIndexReader();
                                 try
                                 {
                                    long time = System.currentTimeMillis();
                                    final Dictionary dict = new LuceneDictionary(reader, FieldNames.FULLTEXT);
                                    log.debug("Starting spell checker index refresh");
                                    SecurityHelper.doPrivilegedIOExceptionAction(new PrivilegedExceptionAction<Void>()
                                    {
                                       public Void run() throws IOException
                                       {
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.