Apache Solr open-source search software
LUCENE-1672: Deprecate all String/File ctors/opens in IndexReader/IndexWriter/IndexSearcher
Uwe Schindler406454d30bc3
diff --git a/CHANGES.txt b/CHANGES.txtindex 411c94f6402..8d313745bbf 100644--- a/CHANGES.txt+++ b/CHANGES.txt@@ -185,6 +185,12 @@ API Changesiterator has exhausted. Otherwise it should return the current doc ID.(Shai Erera via Mike McCandless)+19. LUCENE-1672: All ctors/opens and other methods using String/File to+ specify the directory in IndexReader, IndexWriter, and IndexSearcher+ were deprecated. You should instantiate the Directory manually before+ and pass it to these classes (LUCENE-1451, LUCENE-1658).+ (Uwe Schindler)+Bug fixes1. LUCENE-1415: MultiPhraseQuery has incorrect hashCode() and equals()diff --git a/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/PerfRunData.java b/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/PerfRunData.javaindex 178d69c13ac..4611d49099a 100644--- a/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/PerfRunData.java+++ b/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/PerfRunData.java@@ -128,7 +128,7 @@ public class PerfRunData {FileUtils.fullyDelete(indexDir);}indexDir.mkdirs();- directory = FSDirectory.getDirectory(indexDir);+ directory = FSDirectory.open(indexDir);} else {directory = new RAMDirectory();}diff --git a/contrib/benchmark/src/java/org/apache/lucene/benchmark/quality/utils/QualityQueriesFinder.java b/contrib/benchmark/src/java/org/apache/lucene/benchmark/quality/utils/QualityQueriesFinder.javaindex c20c9286c21..632d7907295 100755--- a/contrib/benchmark/src/java/org/apache/lucene/benchmark/quality/utils/QualityQueriesFinder.java+++ b/contrib/benchmark/src/java/org/apache/lucene/benchmark/quality/utils/QualityQueriesFinder.java@@ -52,7 +52,7 @@ public class QualityQueriesFinder {System.err.println("Usage: java QualityQueriesFinder <index-dir>");System.exit(1);}- QualityQueriesFinder qqf = new QualityQueriesFinder(FSDirectory.getDirectory(new File(args[0])));+ QualityQueriesFinder qqf = new QualityQueriesFinder(FSDirectory.open(new File(args[0])));String q[] = qqf.bestQueries("body",20);for (int i=0; i<q.length; i++) {System.out.println(newline+formatQueryAsTrecTopic(i,q[i],null,null));diff --git a/contrib/benchmark/src/java/org/apache/lucene/benchmark/standard/StandardBenchmarker.java b/contrib/benchmark/src/java/org/apache/lucene/benchmark/standard/StandardBenchmarker.javaindex dce59dd3e79..8a9fe2db250 100644--- a/contrib/benchmark/src/java/org/apache/lucene/benchmark/standard/StandardBenchmarker.java+++ b/contrib/benchmark/src/java/org/apache/lucene/benchmark/standard/StandardBenchmarker.java@@ -92,7 +92,7 @@ public class StandardBenchmarker extends AbstractBenchmarker implements Benchmartry{reset(indexDir);- params[i].setDirectory(FSDirectory.getDirectory(indexDir));+ params[i].setDirectory(FSDirectory.open(indexDir));params[i].setQueries(qds);System.out.println(params[i]);runBenchmark(params[i], options);diff --git a/contrib/benchmark/src/test/org/apache/lucene/benchmark/quality/TestQualityRun.java b/contrib/benchmark/src/test/org/apache/lucene/benchmark/quality/TestQualityRun.javaindex 22686edf317..3cb6503666c 100644--- a/contrib/benchmark/src/test/org/apache/lucene/benchmark/quality/TestQualityRun.java+++ b/contrib/benchmark/src/test/org/apache/lucene/benchmark/quality/TestQualityRun.java@@ -82,7 +82,7 @@ public class TestQualityRun extends TestCase {// validate topics & judgments match each otherjudge.validateData(qqs, logger);- IndexSearcher searcher = new IndexSearcher(FSDirectory.getDirectory(new File(workDir,"index")));+ IndexSearcher searcher = new IndexSearcher(FSDirectory.open(new File(workDir,"index")));QualityQueryParser qqParser = new SimpleQQParser("title","body");QualityBenchmark qrun = new QualityBenchmark(qqs, qqParser, searcher, docNameField);diff --git a/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestIndicesEquals.java b/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestIndicesEquals.javaindex 2cca53b5524..da1444d382d 100644--- a/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestIndicesEquals.java+++ b/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestIndicesEquals.java@@ -47,7 +47,7 @@ import org.apache.lucene.store.RAMDirectory;public class TestIndicesEquals extends TestCase {// public void test2() throws Exception {-// FSDirectory fsdir = FSDirectory.getDirectory("/tmp/fatcorpus");+// FSDirectory fsdir = FSDirectory.open(new File("/tmp/fatcorpus"));// IndexReader ir = IndexReader.open(fsdir);// InstantiatedIndex ii = new InstantiatedIndex(ir);// ir.close();diff --git a/contrib/miscellaneous/src/java/org/apache/lucene/index/FieldNormModifier.java b/contrib/miscellaneous/src/java/org/apache/lucene/index/FieldNormModifier.javaindex dcb31f5eceb..c369c0bd137 100644--- a/contrib/miscellaneous/src/java/org/apache/lucene/index/FieldNormModifier.java+++ b/contrib/miscellaneous/src/java/org/apache/lucene/index/FieldNormModifier.java@@ -17,6 +17,7 @@ package org.apache.lucene.index;*/import java.io.IOException;+import java.io.File;import java.util.Date;import org.apache.lucene.search.Similarity;@@ -62,7 +63,7 @@ public class FieldNormModifier {}}- Directory d = FSDirectory.getDirectory(args[0], false);+ Directory d = FSDirectory.open(new File(args[0]));FieldNormModifier fnm = new FieldNormModifier(d, s);for (int i = 2; i < args.length; i++) {diff --git a/contrib/miscellaneous/src/java/org/apache/lucene/misc/IndexMergeTool.java b/contrib/miscellaneous/src/java/org/apache/lucene/misc/IndexMergeTool.javaindex 6776dc3e2c4..8ea18867117 100644--- a/contrib/miscellaneous/src/java/org/apache/lucene/misc/IndexMergeTool.java+++ b/contrib/miscellaneous/src/java/org/apache/lucene/misc/IndexMergeTool.java@@ -41,7 +41,7 @@ public class IndexMergeTool {Directory[] indexes = new Directory[args.length - 1];for (int i = 1; i < args.length; i++) {- indexes[i - 1] = FSDirectory.getDirectory(args[i], false);+ indexes[i - 1] = FSDirectory.open(new File(args[i]));}System.out.println("Merging...");diff --git a/contrib/miscellaneous/src/java/org/apache/lucene/misc/LengthNormModifier.java b/contrib/miscellaneous/src/java/org/apache/lucene/misc/LengthNormModifier.javaindex af3c21b61de..18ce975cf2f 100644--- a/contrib/miscellaneous/src/java/org/apache/lucene/misc/LengthNormModifier.java+++ b/contrib/miscellaneous/src/java/org/apache/lucene/misc/LengthNormModifier.java@@ -65,7 +65,7 @@ public class LengthNormModifier {}File index = new File(args[0]);- Directory d = FSDirectory.getDirectory(index,false);+ Directory d = FSDirectory.open(index);LengthNormModifier lnm = new LengthNormModifier(d, s);diff --git a/contrib/wordnet/src/java/org/apache/lucene/wordnet/SynExpand.java b/contrib/wordnet/src/java/org/apache/lucene/wordnet/SynExpand.javaindex 92113c0e8c4..97a70d6d9b3 100755--- a/contrib/wordnet/src/java/org/apache/lucene/wordnet/SynExpand.java+++ b/contrib/wordnet/src/java/org/apache/lucene/wordnet/SynExpand.java@@ -19,6 +19,7 @@ package org.apache.lucene.wordnet;import java.io.IOException;import java.io.StringReader;+import java.io.File;import java.util.HashSet;import java.util.Iterator;import java.util.LinkedList;@@ -68,7 +69,7 @@ public final class SynExpand {"java org.apache.lucene.wordnet.SynExpand <index path> <query>");}- FSDirectory directory = FSDirectory.getDirectory(args[0], false);+ FSDirectory directory = FSDirectory.open(new File(args[0]));IndexSearcher searcher = new IndexSearcher(directory);String query = args[1];diff --git a/contrib/wordnet/src/java/org/apache/lucene/wordnet/SynLookup.java b/contrib/wordnet/src/java/org/apache/lucene/wordnet/SynLookup.javaindex 255410935cc..509bbfc7fa6 100644--- a/contrib/wordnet/src/java/org/apache/lucene/wordnet/SynLookup.java+++ b/contrib/wordnet/src/java/org/apache/lucene/wordnet/SynLookup.java@@ -19,6 +19,7 @@ package org.apache.lucene.wordnet;import java.io.IOException;import java.io.StringReader;+import java.io.File;import java.util.HashSet;import java.util.Iterator;import java.util.LinkedList;@@ -51,7 +52,7 @@ public class SynLookup {"java org.apache.lucene.wordnet.SynLookup <index path> <word>");}- FSDirectory directory = FSDirectory.getDirectory(args[0], false);+ FSDirectory directory = FSDirectory.open(new File(args[0]));IndexSearcher searcher = new IndexSearcher(directory);String word = args[1];diff --git a/src/demo/org/apache/lucene/demo/DeleteFiles.java b/src/demo/org/apache/lucene/demo/DeleteFiles.javaindex e8a00b97d11..99593bc7e1c 100644--- a/src/demo/org/apache/lucene/demo/DeleteFiles.java+++ b/src/demo/org/apache/lucene/demo/DeleteFiles.java@@ -17,6 +17,8 @@ package org.apache.lucene.demo;* limitations under the License.*/+import java.io.File;+import org.apache.lucene.store.Directory;import org.apache.lucene.store.FSDirectory;import org.apache.lucene.index.IndexReader;@@ -37,7 +39,7 @@ public class DeleteFiles {System.exit(1);}try {- Directory directory = FSDirectory.getDirectory("index");+ Directory directory = FSDirectory.open(new File("index"));IndexReader reader = IndexReader.open(directory);Term term = new Term("path", args[0]);diff --git a/src/java/org/apache/lucene/index/CheckIndex.java b/src/java/org/apache/lucene/index/CheckIndex.javaindex 2181dbbd13a..0d5ce9e5d85 100644--- a/src/java/org/apache/lucene/index/CheckIndex.java+++ b/src/java/org/apache/lucene/index/CheckIndex.java@@ -26,6 +26,7 @@ import org.apache.lucene.document.Document;import java.text.NumberFormat;import java.io.PrintStream;import java.io.IOException;+import java.io.File;import java.util.Collection;import java.util.Iterator;import java.util.List;@@ -702,7 +703,7 @@ public class CheckIndex {System.out.println("\nOpening index @ " + indexPath + "\n");Directory dir = null;try {- dir = FSDirectory.getDirectory(indexPath);+ dir = FSDirectory.open(new File(indexPath));} catch (Throwable t) {System.out.println("ERROR: could not open directory \"" + indexPath + "\"; exiting");t.printStackTrace(System.out);diff --git a/src/java/org/apache/lucene/index/DirectoryReader.java b/src/java/org/apache/lucene/index/DirectoryReader.javaindex 6dcfaabaa31..b3834419c9b 100644--- a/src/java/org/apache/lucene/index/DirectoryReader.java+++ b/src/java/org/apache/lucene/index/DirectoryReader.java@@ -456,12 +456,16 @@ class DirectoryReader extends IndexReader implements Cloneable {DirectoryReader reader = null;- // While trying to reopen, we temporarily mark our- // closeDirectory as false. This way any exceptions hit- // partway while opening the reader, which is expected- // eg if writer is committing, won't close our- // directory. We restore this value below:- final boolean myCloseDirectory = closeDirectory;+ /* TODO: Remove this in 3.0 - the directory is then+ * no longer owned by the IndexReader and must not be+ * closed.+ * While trying to reopen, we temporarily mark our+ * closeDirectory as false. This way any exceptions hit+ * partway while opening the reader, which is expected+ * eg if writer is committing, won't close our+ * directory. We restore this value below:+ */+ final boolean myCloseDirectory = closeDirectory; // @deprectatedcloseDirectory = false;try {diff --git a/src/java/org/apache/lucene/index/IndexModifier.java b/src/java/org/apache/lucene/index/IndexModifier.javaindex d420edfddd6..75acaaf769a 100644--- a/src/java/org/apache/lucene/index/IndexModifier.java+++ b/src/java/org/apache/lucene/index/IndexModifier.java@@ -97,7 +97,7 @@ public class IndexModifier {protected Directory directory = null;protected Analyzer analyzer = null;- protected boolean open = false;+ protected boolean open = false, closeDir = false;// Lucene defaults:protected PrintStream infoStream = null;@@ -138,6 +138,7 @@ public class IndexModifier {*/public IndexModifier(String dirName, Analyzer analyzer, boolean create) throws CorruptIndexException, LockObtainFailedException, IOException {Directory dir = FSDirectory.getDirectory(dirName);+ this.closeDir = true;init(dir, analyzer, create);}@@ -156,6 +157,7 @@ public class IndexModifier {*/public IndexModifier(File file, Analyzer analyzer, boolean create) throws CorruptIndexException, LockObtainFailedException, IOException {Directory dir = FSDirectory.getDirectory(file);+ this.closeDir = true;init(dir, analyzer, create);}@@ -578,6 +580,10 @@ public class IndexModifier {indexReader = null;}open = false;+ if (closeDir) {+ directory.close();+ }+ closeDir = false;}}diff --git a/src/java/org/apache/lucene/index/IndexReader.java b/src/java/org/apache/lucene/index/IndexReader.javaindex 86968b91dc7..86e37f2fe62 100644--- a/src/java/org/apache/lucene/index/IndexReader.java+++ b/src/java/org/apache/lucene/index/IndexReader.java@@ -204,7 +204,8 @@ public abstract class IndexReader implements Cloneable {* path.* @throws CorruptIndexException if the index is corrupt* @throws IOException if there is a low-level IO error- * @deprecated Use {@link #open(Directory, boolean)} instead+ * @deprecated This method will be removed in the 3.0 release.+ * Use {@link #open(Directory, boolean)} instead* @param path the path to the index directory */public static IndexReader open(String path) throws CorruptIndexException, IOException {return open(FSDirectory.getDirectory(path), true, null, null, false);@@ -220,7 +221,9 @@ public abstract class IndexReader implements Cloneable {* @param path the path to the index directory* @param readOnly true if this should be a readOnly* reader- * @deprecated Use {@link #open(Directory, boolean)} instead*/+ * @deprecated This method will be removed in the 3.0 release.+ * Use {@link #open(Directory, boolean)} instead+ */public static IndexReader open(String path, boolean readOnly) throws CorruptIndexException, IOException {return open(FSDirectory.getDirectory(path), true, null, null, readOnly);}@@ -230,7 +233,8 @@ public abstract class IndexReader implements Cloneable {* @param path the path to the index directory* @throws CorruptIndexException if the index is corrupt* @throws IOException if there is a low-level IO error- * @deprecated Use {@link #open(Directory, boolean)} instead+ * @deprecated This method will be removed in the 3.0 release.+ * Use {@link #open(Directory, boolean)} instead*/public static IndexReader open(File path) throws CorruptIndexException, IOException {return open(FSDirectory.getDirectory(path), true, null, null, false);@@ -246,8 +250,9 @@ public abstract class IndexReader implements Cloneable {* @param path the path to the index directory* @param readOnly true if this should be a readOnly* reader- * @deprecated Use {@link #open(Directory, boolean)}- * instead */+ * @deprecated This method will be removed in the 3.0 release.+ * Use {@link #open(Directory, boolean)} instead+ */public static IndexReader open(File path, boolean readOnly) throws CorruptIndexException, IOException {return open(FSDirectory.getDirectory(path), true, null, null, readOnly);}@@ -257,7 +262,8 @@ public abstract class IndexReader implements Cloneable {* @param directory the index directory* @throws CorruptIndexException if the index is corrupt* @throws IOException if there is a low-level IO error- * @deprecated Use {@link #open(Directory, boolean)} instead+ * @deprecated This method will be removed in the 3.0 release.+ * Use {@link #open(Directory, boolean)} instead*/public static IndexReader open(final Directory directory) throws CorruptIndexException, IOException {return open(directory, false, null, null, false);@@ -281,7 +287,8 @@ public abstract class IndexReader implements Cloneable {* {@link IndexCommit}.* @param commit the commit point to open* @throws CorruptIndexException if the index is corrupt- * @deprecated Use {@link #open(IndexCommit, boolean)} instead+ * @deprecated This method will be removed in the 3.0 release.+ * Use {@link #open(IndexCommit, boolean)} instead* @throws IOException if there is a low-level IO error*/public static IndexReader open(final IndexCommit commit) throws CorruptIndexException, IOException {@@ -308,8 +315,8 @@ public abstract class IndexReader implements Cloneable {* @param deletionPolicy a custom deletion policy (only used* if you use this reader to perform deletes or to set* norms); see {@link IndexWriter} for details.- * @deprecated Use {@link #open(Directory,- * IndexDeletionPolicy, boolean)} instead+ * @deprecated This method will be removed in the 3.0 release.+ * Use {@link #open(Directory, IndexDeletionPolicy, boolean)} instead* @throws CorruptIndexException if the index is corrupt* @throws IOException if there is a low-level IO error*/@@ -344,8 +351,8 @@ public abstract class IndexReader implements Cloneable {* @param deletionPolicy a custom deletion policy (only used* if you use this reader to perform deletes or to set* norms); see {@link IndexWriter} for details.- * @deprecated Use {@link #open(IndexCommit,- * IndexDeletionPolicy, boolean)} instead+ * @deprecated This method will be removed in the 3.0 release.+ * Use {@link #open(IndexCommit, IndexDeletionPolicy, boolean)} instead* @throws CorruptIndexException if the index is corrupt* @throws IOException if there is a low-level IO error*/@@ -500,6 +507,8 @@ public abstract class IndexReader implements Cloneable {* {@link #isCurrent()} instead.* @throws CorruptIndexException if the index is corrupt* @throws IOException if there is a low-level IO error+ * @deprecated This method will be removed in the 3.0 release.+ * Use {@link #lastModified(Directory)} instead*/public static long lastModified(String directory) throws CorruptIndexException, IOException {return lastModified(new File(directory));@@ -511,13 +520,16 @@ public abstract class IndexReader implements Cloneable {* {@link #isCurrent()} instead.* @throws CorruptIndexException if the index is corrupt* @throws IOException if there is a low-level IO error+ * @deprecated This method will be removed in the 3.0 release.+ * Use {@link #lastModified(Directory)} instead*/public static long lastModified(File fileDirectory) throws CorruptIndexException, IOException {- return ((Long) new SegmentInfos.FindSegmentsFile(fileDirectory) {- public Object doBody(String segmentFileName) {- return new Long(FSDirectory.fileModified(fileDirectory, segmentFileName));- }- }.run()).longValue();+ Directory dir = FSDirectory.getDirectory(fileDirectory); // use new static method here+ try {+ return lastModified(dir);+ } finally {+ dir.close();+ }}/**@@ -544,6 +556,8 @@ public abstract class IndexReader implements Cloneable {* @return version number.* @throws CorruptIndexException if the index is corrupt* @throws IOException if there is a low-level IO error+ * @deprecated This method will be removed in the 3.0 release.+ * Use {@link #getCurrentVersion(Directory)} instead*/public static long getCurrentVersion(String directory) throws CorruptIndexException, IOException {return getCurrentVersion(new File(directory));@@ -558,7 +572,8 @@ public abstract class IndexReader implements Cloneable {* @return version number.* @throws CorruptIndexException if the index is corrupt* @throws IOException if there is a low-level IO error- * @deprecated Use {@link #getCurrentVersion(Directory)} instead+ * @deprecated This method will be removed in the 3.0 release.+ * Use {@link #getCurrentVersion(Directory)} instead*/public static long getCurrentVersion(File directory) throws CorruptIndexException, IOException {Directory dir = FSDirectory.getDirectory(directory);@@ -741,6 +756,8 @@ public abstract class IndexReader implements Cloneable {* <code>false</code> is returned.* @param directory the directory to check for an index* @return <code>true</code> if an index exists; <code>false</code> otherwise+ * @deprecated This method will be removed in the 3.0 release.+ * Use {@link #indexExists(Directory)} instead*/public static boolean indexExists(String directory) {return indexExists(new File(directory));@@ -751,6 +768,8 @@ public abstract class IndexReader implements Cloneable {* If the directory does not exist or if there is no index in it.* @param directory the directory to check for an index* @return <code>true</code> if an index exists; <code>false</code> otherwise+ * @deprecated This method will be removed in the 3.0 release.+ * Use {@link #indexExists(Directory)} instead*/public static boolean indexExists(File directory) {@@ -1159,7 +1178,8 @@ public abstract class IndexReader implements Cloneable {* currently locked.* @param directory the directory to check for a lock* @throws IOException if there is a low-level IO error- * @deprecated Please use {@link IndexWriter#isLocked(Directory)} instead+ * @deprecated This method will be removed in the 3.0 release.+ * Please use {@link IndexWriter#isLocked(Directory)} instead*/public static boolean isLocked(Directory directory) throws IOException {return@@ -1171,7 +1191,8 @@ public abstract class IndexReader implements Cloneable {* currently locked.* @param directory the directory to check for a lock* @throws IOException if there is a low-level IO error- * @deprecated Please use {@link IndexWriter#isLocked(Directory)} instead+ * @deprecated This method will be removed in the 3.0 release.+ * Use {@link #isLocked(Directory)} instead*/public static boolean isLocked(String directory) throws IOException {Directory dir = FSDirectory.getDirectory(directory);@@ -1186,7 +1207,8 @@ public abstract class IndexReader implements Cloneable {* Caution: this should only be used by failure recovery code,* when it is known that no other process nor thread is in fact* currently accessing this index.- * @deprecated Please use {@link IndexWriter#unlock(Directory)} instead+ * @deprecated This method will be removed in the 3.0 release.+ * Please use {@link IndexWriter#unlock(Directory)} instead*/public static void unlock(Directory directory) throws IOException {directory.makeLock(IndexWriter.WRITE_LOCK_NAME).release();@@ -1236,7 +1258,7 @@ public abstract class IndexReader implements Cloneable {File file = new File(filename);String dirname = file.getAbsoluteFile().getParent();filename = file.getName();- dir = FSDirectory.getDirectory(dirname);+ dir = FSDirectory.open(new File(dirname));cfr = new CompoundFileReader(dir, filename);String [] files = cfr.list();diff --git a/src/java/org/apache/lucene/index/SegmentInfos.java b/src/java/org/apache/lucene/index/SegmentInfos.javaindex 384f16fa70c..d34ce1c885c 100644--- a/src/java/org/apache/lucene/index/SegmentInfos.java+++ b/src/java/org/apache/lucene/index/SegmentInfos.java@@ -17,7 +17,6 @@ package org.apache.lucene.index;* limitations under the License.*/-import org.apache.lucene.store.FSDirectory;import org.apache.lucene.store.Directory;import org.apache.lucene.store.IndexInput;import org.apache.lucene.store.IndexOutput;@@ -523,13 +522,8 @@ final class SegmentInfos extends Vector {*/public abstract static class FindSegmentsFile {- File fileDirectory;Directory directory;- public FindSegmentsFile(File directory) {- this.fileDirectory = directory;- }-public FindSegmentsFile(Directory directory) {this.directory = directory;}@@ -582,10 +576,7 @@ final class SegmentInfos extends Vector {long genA = -1;- if (directory != null)- files = directory.listAll();- else- files = FSDirectory.listAll(fileDirectory);+ files = directory.listAll();if (files != null)genA = getCurrentSegmentGeneration(files);@@ -732,10 +723,7 @@ final class SegmentInfos extends Vector {gen-1);final boolean prevExists;- if (directory != null)- prevExists = directory.fileExists(prevSegmentFileName);- else- prevExists = new File(fileDirectory, prevSegmentFileName).exists();+ prevExists = directory.fileExists(prevSegmentFileName);if (prevExists) {message("fallback to prior segment file '" + prevSegmentFileName + "'");diff --git a/src/java/org/apache/lucene/search/IndexSearcher.java b/src/java/org/apache/lucene/search/IndexSearcher.javaindex 60e7306effb..56f0351ff84 100644--- a/src/java/org/apache/lucene/search/IndexSearcher.java+++ b/src/java/org/apache/lucene/search/IndexSearcher.java@@ -46,7 +46,7 @@ public class IndexSearcher extends Searcher {/** Creates a searcher searching the index in the named directory.* @throws CorruptIndexException if the index is corrupt* @throws IOException if there is a low-level IO error- * @deprecated Use {@link #IndexSearcher(String, boolean)} instead+ * @deprecated Use {@link #IndexSearcher(Directory, boolean)} instead*/public IndexSearcher(String path) throws CorruptIndexException, IOException {this(IndexReader.open(path), true);@@ -62,6 +62,7 @@ public class IndexSearcher extends Searcher {* will be opened readOnly* @throws CorruptIndexException if the index is corrupt* @throws IOException if there is a low-level IO error+ * @deprecated Use {@link #IndexSearcher(Directory, boolean)} instead*/public IndexSearcher(String path, boolean readOnly) throws CorruptIndexException, IOException {this(IndexReader.open(path, readOnly), true);diff --git a/src/java/overview.html b/src/java/overview.htmlindex 19408dc4953..248c7a9d9f8 100644--- a/src/java/overview.html+++ b/src/java/overview.html@@ -40,7 +40,7 @@ to check if the results are what we expect):</p><font color="#ffffff"> </font><font color="#3f7f5f">// Store the index in memory:</font><br /><font color="#ffffff"> </font><font color="#000000">Directory directory = </font><font color="#7f0055"><b>new </b></font><font color="#000000">RAMDirectory</font><font color="#000000">()</font><font color="#000000">;</font><br /><font color="#ffffff"> </font><font color="#3f7f5f">// To store an index on disk, use this instead:</font><br />-<font color="#ffffff"> </font><font color="#3f7f5f">//Directory directory = FSDirectory.getDirectory("/tmp/testindex");</font><br />+<font color="#ffffff"> </font><font color="#3f7f5f">//Directory directory = FSDirectory.open("/tmp/testindex");</font><br /><font color="#ffffff"> </font><font color="#000000">IndexWriter iwriter = </font><font color="#7f0055"><b>new </b></font><font color="#000000">IndexWriter</font><font color="#000000">(</font><font color="#000000">directory, analyzer, true,</font><br /><font color="#ffffff"> </font><font color="#7f0055"><b>new </b></font><font color="#000000">IndexWriter.MaxFieldLength</font><font color="#000000">(</font><font color="#990000">25000</font><font color="#000000">))</font><font color="#000000">;</font><br /><font color="#ffffff"> </font><font color="#000000">Document doc = </font><font color="#7f0055"><b>new </b></font><font color="#000000">Document</font><font color="#000000">()</font><font color="#000000">;</font><br />diff --git a/src/test/org/apache/lucene/TestDemo.java b/src/test/org/apache/lucene/TestDemo.javaindex 1b432efe84f..6609e7347eb 100644--- a/src/test/org/apache/lucene/TestDemo.java+++ b/src/test/org/apache/lucene/TestDemo.java@@ -49,7 +49,7 @@ public class TestDemo extends LuceneTestCase {// Store the index in memory:Directory directory = new RAMDirectory();// To store an index on disk, use this instead:- //Directory directory = FSDirectory.getDirectory("/tmp/testindex");+ //Directory directory = FSDirectory.open(new File("/tmp/testindex"));IndexWriter iwriter = new IndexWriter(directory, analyzer, true,new IndexWriter.MaxFieldLength(25000));Document doc = new Document();diff --git a/src/test/org/apache/lucene/TestSnapshotDeletionPolicy.java b/src/test/org/apache/lucene/TestSnapshotDeletionPolicy.javaindex ee0e40a4e74..0aa58fe6fab 100644--- a/src/test/org/apache/lucene/TestSnapshotDeletionPolicy.java+++ b/src/test/org/apache/lucene/TestSnapshotDeletionPolicy.java@@ -54,7 +54,7 @@ public class TestSnapshotDeletionPolicy extends LuceneTestCasetry {// Sometimes past test leaves the dir_TestUtil.rmDir(dir);- Directory fsDir = FSDirectory.getDirectory(dir);+ Directory fsDir = FSDirectory.open(dir);runTest(fsDir);fsDir.close();} finally {