mirror of https://github.com/apache/lucene.git
LUCENE-1672: Deprecate all String/File ctors/opens in IndexReader/IndexWriter/IndexSearcher
git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@782469 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a93e2c41b0
commit
406454d30b
|
@ -185,6 +185,12 @@ API Changes
|
|||
iterator 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 fixes
|
||||
|
||||
1. LUCENE-1415: MultiPhraseQuery has incorrect hashCode() and equals()
|
||||
|
|
|
@ -128,7 +128,7 @@ public class PerfRunData {
|
|||
FileUtils.fullyDelete(indexDir);
|
||||
}
|
||||
indexDir.mkdirs();
|
||||
directory = FSDirectory.getDirectory(indexDir);
|
||||
directory = FSDirectory.open(indexDir);
|
||||
} else {
|
||||
directory = new RAMDirectory();
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -92,7 +92,7 @@ public class StandardBenchmarker extends AbstractBenchmarker implements Benchmar
|
|||
try
|
||||
{
|
||||
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);
|
||||
|
|
|
@ -82,7 +82,7 @@ public class TestQualityRun extends TestCase {
|
|||
// validate topics & judgments match each other
|
||||
judge.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);
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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++) {
|
||||
|
|
|
@ -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...");
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -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]);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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; // @deprectated
|
||||
closeDirectory = false;
|
||||
|
||||
try {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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 + "'");
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 />
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -54,7 +54,7 @@ public class TestSnapshotDeletionPolicy extends LuceneTestCase
|
|||
try {
|
||||
// Sometimes past test leaves the dir
|
||||
_TestUtil.rmDir(dir);
|
||||
Directory fsDir = FSDirectory.getDirectory(dir);
|
||||
Directory fsDir = FSDirectory.open(dir);
|
||||
runTest(fsDir);
|
||||
fsDir.close();
|
||||
} finally {
|
||||
|
|
Loading…
Reference in New Issue