Examples of GaeDirectory


Examples of com.googlecode.luceneappengine.GaeDirectory

    if ("".equals(indexName)) {
        request.setAttribute("error", "Index name should be not empty, Operation " + action + " not executed.");
        getServletConfig().getServletContext().getRequestDispatcher("/index.jsp").forward(request, response);
        return;
    }
    try (GaeDirectory directory = new GaeDirectory(indexName); Analyzer analyzer = new PorterAnalyzer(LUCENE_VERSION)){
      final String text = request.getParameter("text");
      final String query = request.getParameter("query");
      final String page = request.getParameter("page");
     
      request.setAttribute("index", indexName);
     
      if("index".equalsIgnoreCase(action)) {
        long start = System.currentTimeMillis();
        try (IndexWriter w = new IndexWriter(directory, getIndexWriterConfig(LUCENE_VERSION, analyzer))) {
            request.setAttribute("info", "Indexed in index '" + indexName + "' string: " + text.substring(0, Math.min(70, text.length())) + (text.length() > 70 ? "..." : ""));
          addDoc(w, text);
        } catch(Exception e) {
          request.setAttribute("message", e.getMessage());
          log.error("Error indexing text {}.", text, e);
        }
        long end = System.currentTimeMillis();
        log.info("Search: {} millis.", end - start);
      } else if("delete".equalsIgnoreCase(action)) {
        try {
          directory.delete();
          request.setAttribute("info", "Successfully deleted index:'" + indexName + "'.");
        } catch (RuntimeException e) {
          request.setAttribute("error", "Error during delete index:'" + indexName + "' cause:" + e.getMessage());
          log.error("Error during delete index '{}'.", indexName, e);
        }
View Full Code Here

Examples of org.apache.lucene.store.GAEDirectory

      }

      long timeStart = System.currentTimeMillis();
      //System.out.println(GAEIndexReaderPool.class.getClassLoader().getResource("indices/" + category + "/index").getFile());
      //File index = new File(GAEIndexReaderPool.class.getClassLoader().getResource("indices/" + category + "/index").getFile());
      GAEDirectory directory = cachedDirectories.get(category);
      if (directory == null) {
        log.info("trying to instance a directory for '" + category + "' version=" + version);
        directory = new GAEDirectory(category, version);
        cachedDirectories.put(category, directory);
      }

      try {
        GAEIndexReader reader = GAEIndexReader.getReader(directory);
View Full Code Here

Examples of org.apache.lucene.store.GAEDirectory

  // reinstance the index reader and update the hashtable entity
  public synchronized void reloadReader(String category, long version) throws IOException {
    GAEIndexReader oldReader = cachedReaders.get(category);

    GAEDirectory directory = new GAEDirectory(category, new Long(version));
    GAEIndexReader newReader = GAEIndexReader.getReader(directory);
    cachedReaders.put(category, newReader);

    if (oldReader != null) {
      oldReader.destory();
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.