congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
DirectoryReader.indexExists
Code IndexAdd Tabnine to your IDE (free)

How to use
indexExists
method
in
org.apache.lucene.index.DirectoryReader

Best Java code snippets using org.apache.lucene.index.DirectoryReader.indexExists (Showing top 20 results out of 387)

origin: oracle/opengrok

private boolean indexExists(final Path indexDir) throws IOException {
  try (Directory indexDirectory = FSDirectory.open(indexDir)) {
    return DirectoryReader.indexExists(indexDirectory);
  }
}
origin: neo4j/neo4j

  private static boolean hasCommits( Directory directory ) throws IOException
  {
    return DirectoryReader.indexExists( directory ) && SegmentInfos.readLatestCommit( directory ) != null;
  }
}
origin: neo4j/neo4j

private boolean luceneDirectoryExists( File folder ) throws IOException
{
  try ( Directory directory = indexStorage.openDirectory( folder ) )
  {
    return DirectoryReader.indexExists( directory );
  }
}
origin: oracle/opengrok

/**
 * 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;
}
origin: org.elasticsearch/elasticsearch

public static boolean indexExists(final Directory directory) throws IOException {
  return DirectoryReader.indexExists(directory);
}
origin: org.apache.lucene/lucene-core

if (!DirectoryReader.indexExists(dir)) {
 throw new IndexNotFoundException(dir.toString());
origin: org.apache.lucene/lucene-core

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;
origin: rnewson/couchdb-lucene

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());
}
origin: Texera/texera

public static boolean checkIndexExistence(Path directory) {
  try {
    return DirectoryReader.indexExists(
        FSDirectory.open(directory));
  } catch (IOException e) {
    return false;
  }
}
 
origin: edu.illinois.cs.cogcomp/big-data-utils

public static boolean indexExists(String pageIndex) {
  try {
    return DirectoryReader.indexExists(new NIOFSDirectory(Paths.get(
        pageIndex)));
  } catch (IOException e) {
    e.printStackTrace();
  }
  return false;
}
origin: CogComp/cogcomp-nlp

public static boolean indexExists(String pageIndex) {
  try {
    return DirectoryReader.indexExists(new NIOFSDirectory(Paths.get(
        pageIndex)));
  } catch (IOException e) {
    e.printStackTrace();
  }
  return false;
}
origin: anylogic/alogic

/**
 * 索引是否已经存在
 * @return true or false
 */
protected boolean indexExists(){
  try {
    return DirectoryReader.indexExists(getDirectory());
  } catch (IOException e) {
    return false;
  }
}
public void build(boolean rebuild) {
origin: edu.illinois.cs.cogcomp/wikiutils

public static boolean indexExists(String pageIndex) {
  try {
    return DirectoryReader.indexExists(new NIOFSDirectory(new File(
        pageIndex)));
  } catch (IOException e) {
    e.printStackTrace();
  }
  return false;
}
origin: apache/roller

private boolean indexExists() {
  try {
    return DirectoryReader.indexExists(getIndexDirectory());
  } catch (IOException e) {
    mLogger.error("Problem accessing index directory", e);
  }
  return false;
}
origin: org.apache.jackrabbit/oak-lucene

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;
}
origin: org.talend.dataquality/dataquality-semantic

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);
  }
}
origin: com.erudika/para-search-lucene

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;
}
origin: apache/jackrabbit-oak

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;
}
origin: senseidb/zoie

 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;
 }
}
origin: javasoze/clue

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);
}

org.apache.lucene.indexDirectoryReaderindexExists

Javadoc

Returns true if an index likely exists at the specified directory. Note that if a corrupt index exists, or if an index in the process of committing

Popular methods of DirectoryReader

  • open
    Returns a IndexReader reading the index in the given Directory
  • close
  • openIfChanged
    Expert: Opens a new reader, if there are any changes, controlling whether past deletions should be a
  • leaves
  • listCommits
    Returns all commit points that exist in the Directory. Normally, because the default is KeepOnlyLast
  • directory
    Returns the directory this index resides in.
  • getIndexCommit
    Expert: return the IndexCommit that this reader has opened.
  • getVersion
    Version number when this IndexReader was opened.This method returns the version recorded in the comm
  • numDocs
  • isCurrent
    Check whether any new changes have occurred to the index since this reader was opened.If this reader
  • decRef
  • document
  • decRef,
  • document,
  • getRefCount,
  • getReaderCacheHelper,
  • maxDoc,
  • tryIncRef,
  • doOpenIfChanged,
  • getSequentialSubReaders,
  • toString

Popular in Java

  • Reading from database using SQL prepared statement
  • getResourceAsStream (ClassLoader)
  • findViewById (Activity)
  • setRequestProperty (URLConnection)
  • FileNotFoundException (java.io)
    Thrown when a file specified by a program cannot be found.
  • Date (java.sql)
    A class which can consume and produce dates in SQL Date format. Dates are represented in SQL as yyyy
  • DecimalFormat (java.text)
    A concrete subclass of NumberFormat that formats decimal numbers. It has a variety of features desig
  • UUID (java.util)
    UUID is an immutable representation of a 128-bit universally unique identifier (UUID). There are mul
  • ThreadPoolExecutor (java.util.concurrent)
    An ExecutorService that executes each submitted task using one of possibly several pooled threads, n
  • Location (org.springframework.beans.factory.parsing)
    Class that models an arbitrary location in a Resource.Typically used to track the location of proble
  • Best plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now