private boolean indexExists(final Path indexDir) throws IOException { try (Directory indexDirectory = FSDirectory.open(indexDir)) { return DirectoryReader.indexExists(indexDirectory); } }
private static boolean hasCommits( Directory directory ) throws IOException { return DirectoryReader.indexExists( directory ) && SegmentInfos.readLatestCommit( directory ) != null; } }
private boolean luceneDirectoryExists( File folder ) throws IOException { try ( Directory directory = indexStorage.openDirectory( folder ) ) { return DirectoryReader.indexExists( directory ); } }
/** * Get an indexReader for the Index database where a given file * * @param path the file to get the database for * @return The index database where the file should be located or null if it * cannot be located. */ public static IndexReader getIndexReader(String path) { IndexReader ret = null; RuntimeEnvironment env = RuntimeEnvironment.getInstance(); File indexDir = new File(env.getDataRootFile(), INDEX_DIR); if (env.hasProjects()) { Project p = Project.getProject(path); if (p == null) { return null; } indexDir = new File(indexDir, p.getPath()); } try { FSDirectory fdir = FSDirectory.open(indexDir.toPath(), NoLockFactory.INSTANCE); if (indexDir.exists() && DirectoryReader.indexExists(fdir)) { ret = DirectoryReader.open(fdir); } } catch (Exception ex) { LOGGER.log(Level.SEVERE, "Failed to open index: {0}", indexDir.getAbsolutePath()); LOGGER.log(Level.FINE, "Stack Trace: ", ex); } return ret; }
public static boolean indexExists(final Directory directory) throws IOException { return DirectoryReader.indexExists(directory); }
if (!DirectoryReader.indexExists(dir)) { throw new IndexNotFoundException(dir.toString());
final boolean create; if (mode == OpenMode.CREATE) { indexExists = DirectoryReader.indexExists(directory); create = true; } else if (mode == OpenMode.APPEND) { } else { indexExists = DirectoryReader.indexExists(directory); create = !indexExists;
private UpdateSequence getUpdateSequence(final Directory dir) throws IOException { if (!DirectoryReader.indexExists(dir)) { return UpdateSequence.START; } final List<IndexCommit> commits = DirectoryReader.listCommits(dir); final IndexCommit latest = commits.get(commits.size() - 1); return getUpdateSequence(latest.getUserData()); }
public static boolean checkIndexExistence(Path directory) { try { return DirectoryReader.indexExists( FSDirectory.open(directory)); } catch (IOException e) { return false; } }
public static boolean indexExists(String pageIndex) { try { return DirectoryReader.indexExists(new NIOFSDirectory(Paths.get( pageIndex))); } catch (IOException e) { e.printStackTrace(); } return false; }
public static boolean indexExists(String pageIndex) { try { return DirectoryReader.indexExists(new NIOFSDirectory(Paths.get( pageIndex))); } catch (IOException e) { e.printStackTrace(); } return false; }
/** * 索引是否已经存在 * @return true or false */ protected boolean indexExists(){ try { return DirectoryReader.indexExists(getDirectory()); } catch (IOException e) { return false; } } public void build(boolean rebuild) {
public static boolean indexExists(String pageIndex) { try { return DirectoryReader.indexExists(new NIOFSDirectory(new File( pageIndex))); } catch (IOException e) { e.printStackTrace(); } return false; }
private boolean indexExists() { try { return DirectoryReader.indexExists(getIndexDirectory()); } catch (IOException e) { mLogger.error("Problem accessing index directory", e); } return false; }
private static long getLatestGeneration(Directory directory) throws IOException { if (DirectoryReader.indexExists(directory)) { List<IndexCommit> commits = DirectoryReader.listCommits(directory); if (!commits.isEmpty()) { //Look for that last commit as list is sorted from oldest to latest return commits.get(commits.size() - 1).getGeneration(); } } return -1; }
private void init() { try { boolean isLuceneDir = DirectoryReader.indexExists(directory); if (!isLuceneDir) { LOGGER.debug("Document index is not a lucene index, trying to initialize an empty lucene index "); commitChanges(); } mgr = new SearcherManager(directory, null); } catch (IOException e) { LOGGER.error(e.getMessage(), e); } }
private static DirectoryReader getIndexReader(String appid) { try { String dataDir = Config.getConfigParam("lucene.dir", Paths.get(".").toAbsolutePath().normalize().toString()); Path path = FileSystems.getDefault().getPath(dataDir, "data", getIndexName(appid)); FSDirectory indexDir = FSDirectory.open(path); if (DirectoryReader.indexExists(indexDir)) { return DirectoryReader.open(indexDir); } } catch (IOException ex) { logger.warn("Couldn't get IndexReader - '{}' does not exist: {}", getIndexName(appid), ex.getMessage()); } return null; }
private static long getLatestGeneration(Directory directory) throws IOException { if (DirectoryReader.indexExists(directory)) { List<IndexCommit> commits = DirectoryReader.listCommits(directory); if (!commits.isEmpty()) { //Look for that last commit as list is sorted from oldest to latest return commits.get(commits.size() - 1).getGeneration(); } } return -1; }
private DirectoryReader getArchive(ZoieSystem<R, D> zoie) throws CorruptIndexException, IOException { String dirName = zoie.getAdminMBean().getIndexDir(); Directory dir = new SimpleFSDirectory(new File(dirName)); DirectoryReader reader = null; if (DirectoryReader.indexExists(dir)) { reader = DirectoryReader.open(dir); } else { log.info("empty index " + dirName); reader = null; } return reader; } }
public ClueApplication(String idxLocation, boolean interactiveMode) throws Exception{ dir = config.getDirBuilder().build(new URI(idxLocation)); if (!DirectoryReader.indexExists(dir)){ System.out.println("lucene index does not exist at: "+idxLocation); System.exit(1); } ctx = newContext(dir, config, interactiveMode); helpCommand = ctx.getCommand(HelpCommand.CMD_NAME); }