Package org.apache.lucene.store

Examples of org.apache.lucene.store.FSDirectory

Unfortunately, because of system peculiarities, there is no single overall best implementation. Therefore, we've added the {@link #open} method, to allow Lucene to choosethe best FSDirectory implementation given your environment, and the known limitations of each implementation. For users who have no reason to prefer a specific implementation, it's best to simply use {@link #open}. For all others, you should instantiate the desired implementation directly.

The locking implementation is by default {@link NativeFSLockFactory}, but can be changed by passing in a custom {@link LockFactory} instance. @see Directory


   * @throws java.io.IOException if an error
   */
  public static FSDirectory createFSIndex(File indexDir, Properties properties) throws IOException {
    LockFactory lockFactory = createLockFactory( indexDir, properties );
    FSDirectoryType fsDirectoryType = FSDirectoryType.getType( properties );
    FSDirectory fsDirectory = fsDirectoryType.getDirectory( indexDir, null );

    // must use the setter (instead of using the constructor) to set the lockFactory, or Lucene will
    // throw an exception if it's different than a previous setting.
    fsDirectory.setLockFactory( lockFactory );
    log.debugf( "Initialize index: '%s'", indexDir.getAbsolutePath() );
    initializeIndexIfNeeded( fsDirectory );
    return fsDirectory;
  }
View Full Code Here


   * @throws IOException if an error
   */
  public static FSDirectory createFSIndex(File indexDir, Properties properties) throws IOException {
    LockFactory lockFactory = createLockFactory( indexDir, properties );
    FSDirectoryType fsDirectoryType = FSDirectoryType.getType( properties );
    FSDirectory fsDirectory = fsDirectoryType.getDirectory( indexDir, null );

    // must use the setter (instead of using the constructor) to set the lockFactory, or Lucene will
    // throw an exception if it's different than a previous setting.
    fsDirectory.setLockFactory( lockFactory );
    log.debugf( "Initialize index: '%s'", indexDir.getAbsolutePath() );
    initializeIndexIfNeeded( fsDirectory );
    return fsDirectory;
  }
View Full Code Here

      if (adapter == null) {
         synchronized (openDirectories) {
            adapter = openDirectories.get(indexName);
            if (adapter == null) {
               final File path = new File(this.rootDirectory, indexName);
               final FSDirectory directory = openLuceneDirectory(path);
               final InternalDirectoryContract wrapped = ContractAdaptorFactory.wrapNativeDirectory(directory);
               adapter = new DirectoryLoaderAdaptor(wrapped, indexName, autoChunkSize);
               openDirectories.put(indexName, adapter);
            }
         }
View Full Code Here

      if (adapter == null) {
         synchronized (openDirectories) {
            adapter = openDirectories.get(indexName);
            if (adapter == null) {
               final File path = new File(this.rootDirectory, indexName);
               final FSDirectory directory = openLuceneDirectory(path);
               adapter = new DirectoryLoaderAdaptor(directory, indexName, autoChunkSize);
               openDirectories.put(indexName, adapter);
            }
         }
      }
View Full Code Here

   * @throws IOException if an error
   */
  public static FSDirectory createFSIndex(File indexDir, Properties properties) throws IOException {
    LockFactory lockFactory = createLockFactory( indexDir, properties );
    FSDirectoryType fsDirectoryType = FSDirectoryType.getType( properties );
    FSDirectory fsDirectory = fsDirectoryType.getDirectory( indexDir, null );

    // must use the setter (instead of using the constructor) to set the lockFactory, or Lucene will
    // throw an exception if it's different than a previous setting.
    fsDirectory.setLockFactory( lockFactory );
    log.debugf( "Initialize index: '%s'", indexDir.getAbsolutePath() );
    initializeIndexIfNeeded( fsDirectory );
    return fsDirectory;
  }
View Full Code Here

   * @throws IOException if an error
   */
  public static FSDirectory createFSIndex(File indexDir, Properties properties) throws IOException {
    LockFactory lockFactory = createLockFactory( indexDir, properties );
    FSDirectoryType fsDirectoryType = FSDirectoryType.getType( properties );
    FSDirectory fsDirectory = fsDirectoryType.getDirectory( indexDir, null );

    // must use the setter (instead of using the constructor) to set the lockFactory, or Lucene will
    // throw an exception if it's different than a previous setting.
    fsDirectory.setLockFactory( lockFactory );
    log.debug( "Initialize index: '{}'", indexDir.getAbsolutePath() );
    initializeIndexIfNeeded( fsDirectory );
    return fsDirectory;
  }
View Full Code Here

    tableDescriptor.putToTableProperties("blur.shard.time.between.refreshs", Long.toString(refresh));

    TableContext tableContext = TableContext.create(tableDescriptor);
    File path = new File(base, "index_" + uuid);
    path.mkdirs();
    FSDirectory directory = FSDirectory.open(path);
    ShardContext shardContext = ShardContext.create(tableContext, "test-shard-" + uuid);
    writer = new BlurNRTIndex(shardContext, mergeScheduler, closer, directory, gc, service);
  }
View Full Code Here

    infos.commit(fsDir);
  }

  public void split(File destDir, String[] segs) throws IOException {
    destDir.mkdirs();
    FSDirectory destFSDir = FSDirectory.open(destDir);
    SegmentInfos destInfos = new SegmentInfos();
    for (String n : segs) {
      SegmentInfo info = getInfo(n);
      destInfos.add(info);
      // now copy files over
View Full Code Here

    }
   
    File topicsFile = new File(args[0]);
    File qrelsFile = new File(args[1]);
    SubmissionReport submitLog = new SubmissionReport(new PrintWriter(args[2]), "lucene");
    FSDirectory dir = FSDirectory.open(new File(args[3]));
    Searcher searcher = new IndexSearcher(dir, true);

    int maxResults = 1000;
    String docNameField = "docname";
View Full Code Here

                url = new URL(a[++i]);
            }
        }

        PrintStream o = System.out;
        FSDirectory dir = FSDirectory.open(new File(indexName));
        IndexReader r = IndexReader.open(dir, true);
        o.println("Open index " + indexName + " which has " + r.numDocs() + " docs");

        MoreLikeThis mlt = new MoreLikeThis(r);
View Full Code Here

TOP

Related Classes of org.apache.lucene.store.FSDirectory

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.