Package net.sf.regain

Examples of net.sf.regain.RegainException


                new String(fieldContent));
      }

    }
    catch (RegainException exc) {
      throw new RegainException("Getting hit #" + hitIndex + " failed", exc);
    }
  }
View Full Code Here


      try {
        mIndexSearcher = new IndexSearcher(FSDirectory.open(mWorkingIndexDir),true);
      }
      catch (IOException exc) {
        throw new RegainException("Creating index searcher failed", exc);
      }
    }

    try {
      TopScoreDocCollector collector = TopScoreDocCollector.create(20, false);
      mIndexSearcher.search(query, collector);
      return collector.topDocs().scoreDocs;

    } catch (IOException exc) {
      throw new RegainException("Searching query failed", exc);
    }
  }
View Full Code Here

      try {
        mIndexReader = IndexReader.open(FSDirectory.open(mWorkingIndexDir),true);
      }
      catch (IOException exc) {
        throw new RegainException("Creating index reader failed", exc);
      }
    }

    return mIndexReader;
  }
View Full Code Here

        checkForIndexUpdate();
      }

      if (! mWorkingIndexDir.exists()) {
        // There is no working and no new index -> throw exception
        throw new RegainException("No index found in "
            + mWorkingIndexDir.getParentFile().getAbsolutePath());
      }

      // Read the stopWordList and the exclusionList
      File analyzerTypeFile = new File(mWorkingIndexDir, "analyzerType.txt");
View Full Code Here

      if (mIndexSearcher != null) {
        try {
          mIndexSearcher.close();
        }
        catch (IOException exc) {
          throw new RegainException("Closing index searcher failed", exc);
        }

        // Force the creation of a new IndexSearcher and Analyzer next time it
        // will be needed
        mIndexSearcher = null;
        mAnalyzer = null;
      }

      // Close the IndexReader
      if (mIndexReader != null) {
        try {
          mIndexReader.close();
        }
        catch (IOException exc) {
          throw new RegainException("Closing index reader failed", exc);
        }

        // Force the creation of a new IndexReader and mFieldTermHash next time
        // it will be needed
        mIndexReader = null;
        mFieldTermHash = null;
      }

      // Remove the old backup if it should still exist
      if (mBackupIndexDir.exists()) {
        RegainToolkit.deleteDirectory(mBackupIndexDir);
      }

      // Backup the current index (if there is one)
      if (mWorkingIndexDir.exists()) {
        if (! mWorkingIndexDir.renameTo(mBackupIndexDir)) {
          throw new RegainException("Renaming " + mWorkingIndexDir + " to "
            + mBackupIndexDir + " failed!");
        }
      }

      // Move the new index
      if (! mNewIndexDir.renameTo(mWorkingIndexDir)) {
        throw new RegainException("Renaming " + mNewIndexDir + " to "
          + mWorkingIndexDir + " failed!");
      }
    }
  }
View Full Code Here

    Query rewittenQuery = query;
    if (mIndexSearcher != null) {
      try {
        rewittenQuery = getIndexSearcher().rewrite(query);
      } catch (IOException e) {
        throw new RegainException("Rewriting of query: " + query.toString() + " failed. " + e.getMessage());
      }
    }
    return rewittenQuery;
  }
View Full Code Here

      try {
        mIndexSearcher = new IndexSearcher(FSDirectory.open(mWorkingIndexDir),true);
      }
      catch (IOException exc) {
        throw new RegainException("Creating index searcher failed", exc);
      }
    }

    return mIndexSearcher;
  }
View Full Code Here

      byte[] compressedFieldValue = hit.getBinaryValue(field);
      if (compressedFieldValue != null) {
        try {
          value = CompressionTools.decompressString(compressedFieldValue);
        } catch (DataFormatException dataFormatException) {
          throw new RegainException("Couldn't uncompress field value." + dataFormatException);
        }
      }
    }

    if (value != null) {
View Full Code Here

        strWriter.close();
       
        response.printNoHtml(strWriter.toString());
      }
      catch (IOException exc) {
        throw new RegainException("Printing stacktrace failed", exc);
      }
    }
  }
View Full Code Here

    fieldHash.add(PATH);

    // Check the validity of the new option
    if (this.description == null || this.description.length() < 3 ||
            !fieldHash.contains(this.sortFieldName) || this.id < 0) {
      throw new RegainException("The sorting option is not properly defined.");
    }
  }
View Full Code Here

TOP

Related Classes of net.sf.regain.RegainException

Copyright © 2018 www.massapicom. 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.