lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 36242] New: - Creating a new index vs. opening an existing one
Date Thu, 18 Aug 2005 12:42:56 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=36242>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=36242

           Summary: Creating a new index vs. opening an existing one
           Product: Lucene
           Version: 1.4
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P5
         Component: Index
        AssignedTo: java-dev@lucene.apache.org
        ReportedBy: mikko@noromaa.fi


Currently I have to tell the IndexWriter constructor whether I want a new 
index created or not. The behaviour I'd like is to open an index if one 
exists, or create a new one if it doesn't exist.

Now I check for a 'segments' file in my code to make the choice:

boolean CreateNew=false;
	
// Create a new index ONLY if one doesn't exist already. Even then, we first 
try to open
// an existing index.
if (!(new java.io.File(IndexPath+"\\segments")).exists()) {
	CreateNew=true;
}
	
try {
	writer = new IndexWriter(IndexPath, new StandardAnalyzer(), false);
}
catch (IOException e) {
	if (CreateNew) {
		writer = new IndexWriter(IndexPath, new StandardAnalyzer(), 
true);
	}
	else {
		throw e;
	}
}


I believe this logic would make more sense inside Lucene.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


Mime
View raw message