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


    }
   
    if(localdp == null)
      return null;
   
    FSDirectory dir = localdp.getDirectory();
    File indexRoot = dir.getFile();
    if (key == null) {
      File[] subIndex = indexRoot.listFiles();
      for (File sub : subIndex) {
        localDirectoryToMap(sub.getName());
      }
      return localdp;
    }
    DirectoryProvider dp = providerMap.get(key);
    if (dp != null)
      return dp;
    File indexFile = new File(indexRoot, key);
    String indexName = "";
    boolean create = !indexFile.exists();
    FSDirectory directory = null;
    try {
      indexName = indexFile.getCanonicalPath();
      directory = FSDirectory.getDirectory(indexName);
      if (create) {
        log.debug("Initialize index: '" + indexFile + "'");
View Full Code Here


   */
  public static void main(String[] args) throws Exception
  {
    File file = new File("/Users/jwang/dataset/facet_idx_2/beef");

    FSDirectory idxDir = FSDirectory.open(file);
   
    IndexReader reader = IndexReader.open(idxDir,true);
   
    long start =System.currentTimeMillis();
    BoboIndexReader boboReader = BoboIndexReader.getInstance(reader);
View Full Code Here

    System.out.println(Arrays.toString(args));
    String filename = "/Users/xgu/lucene29test/caches/people-search-index";
    if (args.length>0) filename ="/Users/xgu/lucene29test/caches/people-search-index";
    System.out.println(filename);
    File file = new File(filename);
    FSDirectory directory = new SimpleFSDirectory(file);
//    FSDirectory directory = FSDirectory.getDirectory(file);
    System.out.println(directory.getClass().getName());
    IndexReader reader = IndexReader.open(directory, true);
    loadFile();
//    TermEnum termEnum = reader.terms(new Term("b", ""));
//    while(termEnum.next())
//    {
View Full Code Here

    if (facetHandlers == null) // try to load from index
    {
      Directory idxDir = directory();
      if (idxDir != null && idxDir instanceof FSDirectory)
      {
        FSDirectory fsDir = (FSDirectory) idxDir;
        File file = fsDir.getFile();

        if (new File(file, SPRING_CONFIG).exists())
        {
          facetHandlers = loadFromIndex(file,_workArea);
        }
View Full Code Here

  //*-- otherwise, delete the existing index for the document
  //*-- should occur only for modified documents
  else
  { try 
     { synchronized(this)
       { FSDirectory fsd = FSDirectory.getDirectory(new File(Constants.getINDEXDIR()), false);
         IndexReader ir = IndexReader.open(fsd);
         ir.deleteDocuments(new Term("key", iDocument ) );
         ir.close();
       }
      }
View Full Code Here

    } //*-- end of outer if
    ++count;
   } //*-- end of while

   //*-- clean up the Lucene index
   FSDirectory fsd = FSDirectory.getDirectory(new File(Constants.getINDEXDIR()), false);
   IndexReader ir = IndexReader.open(fsd);
   for (int i = 0; i < delFiles.size(); i++)
    ir.deleteDocuments(new Term("key", (String) delFiles.get(i)) );
   ir.close();
  }
View Full Code Here

  // The top numTerms will be displayed
  public static final int numTerms = 100;

  public static void main(String[] args) throws Exception {
    IndexReader reader = null;
    FSDirectory dir = null;
    String field = null;
    if (args.length == 1) {
      dir = FSDirectory.open(new File(args[0]));
      reader = IndexReader.open(dir, true);
    } else if (args.length == 2) {
View Full Code Here

  public static void main(String[] args) throws IOException {
    if (args.length < 3) {
      System.err.println("Usage: IndexMergeTool <mergedIndex> <index1> <index2> [index3] ...");
      System.exit(1);
    }
    FSDirectory mergedIndex = FSDirectory.open(new File(args[0]));

    IndexWriter writer = new IndexWriter(mergedIndex, new  SimpleAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);

    Directory[] indexes = new Directory[args.length - 1];
    for (int i = 1; i < args.length; i++) {
View Full Code Here

    {
      System.out.println(
                 "java org.apache.lucene.wordnet.SynExpand <index path> <query>");
    }

    FSDirectory directory = FSDirectory.open(new File(args[0]));
    IndexSearcher searcher = new IndexSearcher(directory, true);

    String query = args[1];
    String field = "contents";

    Query q = expand( query, searcher, new StandardAnalyzer(Version.LUCENE_CURRENT), field, 0.9f);
    System.out.println( "Query: " + q.toString( field));



    searcher.close();
    directory.close();
  }
View Full Code Here

    if (args.length != 2) {
      System.out.println(
                 "java org.apache.lucene.wordnet.SynLookup <index path> <word>");
    }

    FSDirectory directory = FSDirectory.open(new File(args[0]));
    IndexSearcher searcher = new IndexSearcher(directory, true);

    String word = args[1];
    Query query = new TermQuery(new Term(Syns2Index.F_WORD, word));
    CountingCollector countingCollector = new CountingCollector();
    searcher.search(query, countingCollector);

    if (countingCollector.numHits == 0) {
      System.out.println("No synonyms found for " + word);
    } else {
      System.out.println("Synonyms found for \"" + word + "\":");
    }

    ScoreDoc[] hits = searcher.search(query, countingCollector.numHits).scoreDocs;
   
    for (int i = 0; i < hits.length; i++) {
      Document doc = searcher.doc(hits[i].doc);

      String[] values = doc.getValues(Syns2Index.F_SYN);

      for (int j = 0; j < values.length; j++) {
        System.out.println(values[j]);
      }
    }

    searcher.close();
    directory.close();
  }
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.