Package com.googlecode.luceneappengine
Class GaeDirectory
java.lang.Object
org.apache.lucene.store.Directory
org.apache.lucene.store.BaseDirectory
com.googlecode.luceneappengine.GaeDirectory
- All Implemented Interfaces:
Closeable
,AutoCloseable
Lucene
If your application throws
Directory
working in google app engine (GAE) environment.
Using this Directory
you can create multiple indexes, each one identified by
a name specified in constructor GaeDirectory(LaeContext, String)
,
for details read constructor documentation.
In order to open an index writer is highly recommended the usage of configuration provided by
GaeLuceneUtil.getIndexWriterConfig(org.apache.lucene.analysis.Analyzer)
.
GaeDirectory directory = new GaeDirectory();
IndexWriterConfig config = GaeLuceneUtil.getIndexWriterConfig(Version.LATEST, analyzer);
IndexWriter writer = new IndexWriter(directory, config);
If your application throws
NoClassDefFoundError
while using GaeDirectory
in order to make it work, into your GAE web application, the modified RamUsageEstimator
(link to source)
in a package named org.apache.lucene.util
.
- Author:
- Fabio Grucci (github: UltimaPhoenix, bitbucket: Dark_Phoenix, googlecode: fabio.grucci)
- See Also:
-
Field Summary
Fields inherited from class org.apache.lucene.store.BaseDirectory
isOpen, lockFactory
-
Constructor Summary
ConstructorsConstructorDescriptionGaeDirectory
(LaeContext laeContext) Create aGaeDirectory
with default name"defaultIndex"
.GaeDirectory
(LaeContext laeContext, LuceneIndex luceneIndex) Create aGaeDirectory
for existing index.GaeDirectory
(LaeContext laeContext, String indexName) Create aGaeDirectory
with specified name, the name specified must be a legalDocumentId
name. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
createOutput
(String name, IOContext context) createTempOutput
(String prefix, String suffix, IOContext context) void
delete()
Delete this directory.void
deleteFile
(String name) long
fileLength
(String name) static List<LuceneIndex>
getAvailableIndexes
(LaeContext context) Returns every available indexes created into your GAE application.String[]
listAll()
protected Segment
newSegment
(String name) Create a new file in the index.void
void
sync
(Collection<String> names) void
Methods inherited from class org.apache.lucene.store.BaseDirectory
ensureOpen, obtainLock, toString
Methods inherited from class org.apache.lucene.store.Directory
copyFrom, getTempFileName, openChecksumInput
-
Constructor Details
-
GaeDirectory
Create aGaeDirectory
with default name"defaultIndex"
. Same asGaeDirectory(LaeContext, String)
with"defaultIndex"
.- Parameters:
laeContext
- the laecontext
-
GaeDirectory
Create aGaeDirectory
with specified name, the name specified must be a legalDocumentId
name.- Parameters:
laeContext
- The lae contextindexName
- The name of the index
-
GaeDirectory
Create aGaeDirectory
for existing index.- Parameters:
laeContext
- The laecontextluceneIndex
- The existing index
-
-
Method Details
-
getAvailableIndexes
Returns every available indexes created into your GAE application. WithLuceneIndex
you can buildGaeDirectory
using constructorGaeDirectory(LaeContext, LuceneIndex)
.- Parameters:
context
- The lae context- Returns:
- A list of available indexes
-
delete
Delete this directory.- Throws:
IOException
- If an error occurs
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in classDirectory
- Throws:
IOException
-
getPendingDeletions
- Specified by:
getPendingDeletions
in classDirectory
-
openInput
- Specified by:
openInput
in classDirectory
- Throws:
IOException
-
createOutput
- Specified by:
createOutput
in classDirectory
- Throws:
IOException
-
createTempOutput
public IndexOutput createTempOutput(String prefix, String suffix, IOContext context) throws IOException - Specified by:
createTempOutput
in classDirectory
- Throws:
IOException
-
deleteFile
- Specified by:
deleteFile
in classDirectory
-
rename
- Specified by:
rename
in classDirectory
- Throws:
IOException
-
fileLength
- Specified by:
fileLength
in classDirectory
- Throws:
IOException
-
listAll
-
newSegment
Create a new file in the index.- Parameters:
name
- The name of the segment/file- Returns:
- the instance of the Segment
- Throws:
ExecutionException
- If an error occursInterruptedException
- If the thread is interrupted
-
sync
- Specified by:
sync
in classDirectory
- Throws:
IOException
-
syncMetaData
- Specified by:
syncMetaData
in classDirectory
- Throws:
IOException
-