public class DefaultIndexingContext extends AbstractIndexingContext
IndexingContext
implementation.Modifier and Type | Field and Description |
---|---|
static String |
FLD_DESCRIPTOR |
static String |
FLD_DESCRIPTOR_CONTENTS |
static String |
FLD_IDXINFO |
static String |
VERSION |
INDEX_CHAIN_ID, INDEX_CHUNK_COUNTER, INDEX_CHUNK_PREFIX, INDEX_FILE_PREFIX, INDEX_ID, INDEX_LEGACY_TIMESTAMP, INDEX_PACKER_PROPERTIES_FILE, INDEX_PROPERTY_PREFIX, INDEX_REMOTE_PROPERTIES_FILE, INDEX_TIME_DAY_FORMAT, INDEX_TIME_FORMAT, INDEX_TIMESTAMP, INDEX_UPDATER_PROPERTIES_FILE
Constructor and Description |
---|
DefaultIndexingContext(String id,
String repositoryId,
File repository,
org.apache.lucene.store.Directory indexDirectory,
String repositoryUrl,
String indexUpdateUrl,
List<? extends IndexCreator> indexCreators,
boolean reclaimIndex)
Deprecated.
|
DefaultIndexingContext(String id,
String repositoryId,
File repository,
File indexDirectoryFile,
String repositoryUrl,
String indexUpdateUrl,
List<? extends IndexCreator> indexCreators,
boolean reclaimIndex) |
Modifier and Type | Method and Description |
---|---|
org.apache.lucene.search.IndexSearcher |
acquireIndexSearcher()
Acquires a fresh instance of
IndexSearcher . |
void |
close(boolean deleteFiles)
Shuts down this context.
|
void |
commit()
Commits changes to context, eventually refreshing readers/searchers too.
|
protected org.apache.lucene.document.Document |
createGroupsDocument(Collection<String> groups,
String field,
String fieldValue,
String listField) |
Set<String> |
getAllGroups()
Gets all group names stored in the current indexing context
|
org.apache.lucene.analysis.Analyzer |
getAnalyzer()
Returns the Lucene Analyzer of this context used for by IndexWriter and IndexSearcher.
|
GavCalculator |
getGavCalculator()
Returns the GavCalculator for this Context.
|
protected Set<String> |
getGroups(String field,
String filedValue,
String listField) |
String |
getId()
Returns this indexing context id.
|
List<IndexCreator> |
getIndexCreators()
List of IndexCreators used in this context.
|
org.apache.lucene.store.Directory |
getIndexDirectory() |
File |
getIndexDirectoryFile() |
String |
getIndexUpdateUrl()
Returns url for the index update
|
org.apache.lucene.index.IndexWriter |
getIndexWriter()
Returns the Lucene IndexWriter (thread safe, shared instance) of this context.
|
File |
getRepository()
Returns location for the local repository.
|
String |
getRepositoryId()
Returns repository id.
|
String |
getRepositoryUrl()
Returns public repository url.
|
Set<String> |
getRootGroups()
Gets root group names stored in the current indexing context
|
int |
getSize()
Returns a number that represents the "size" useful for doing comparisons between contexts (which one has more
data indexed?).
|
Date |
getTimestamp()
Returns index update time
|
protected org.apache.lucene.index.IndexWriterConfig |
getWriterConfig()
Returns new IndexWriterConfig instance
|
boolean |
isSearchable()
Is the context searchable when doing "non-targeted" searches?
|
void |
merge(org.apache.lucene.store.Directory directory)
Merges content of given Lucene directory with this context.
|
void |
merge(org.apache.lucene.store.Directory directory,
DocumentFilter filter)
Merges content of given Lucene directory with this context, but filters out the unwanted ones.
|
protected void |
openAndWarmup() |
void |
optimize()
Optimizes index.
|
void |
purge()
Purge (cleans) the context, deletes/empties the index and restores the context to new/empty state.
|
void |
rebuildGroups()
Rebuilds stored group names from the index
|
void |
releaseIndexSearcher(org.apache.lucene.search.IndexSearcher is)
Releases the
IndexSearcher instance. |
void |
replace(org.apache.lucene.store.Directory directory)
Replaces the Lucene index with the one from supplied directory.
|
void |
replace(org.apache.lucene.store.Directory directory,
Set<String> allGroups,
Set<String> rootGroups) |
void |
rollback()
Rolls back changes to context, eventually refreshing readers/searchers too.
|
void |
setAllGroups(Collection<String> groups)
Sets all group names stored in the current indexing context
|
protected void |
setGroups(Collection<String> groups,
String groupField,
String groupFieldValue,
String groupListField) |
protected void |
setIndexDirectoryFile(File dir)
Sets index location.
|
void |
setRootGroups(Collection<String> groups)
Sets root group names stored in the current indexing context
|
void |
setSearchable(boolean searchable)
Sets is the context searchable when doing "non-targeted" searches.
|
String |
toString() |
void |
updateTimestamp() |
void |
updateTimestamp(boolean save) |
void |
updateTimestamp(boolean save,
Date timestamp) |
isReceivingUpdates
public static final String FLD_DESCRIPTOR
public static final String FLD_DESCRIPTOR_CONTENTS
public static final String FLD_IDXINFO
public static final String VERSION
public DefaultIndexingContext(String id, String repositoryId, File repository, File indexDirectoryFile, String repositoryUrl, String indexUpdateUrl, List<? extends IndexCreator> indexCreators, boolean reclaimIndex) throws IOException, ExistingLuceneIndexMismatchException
@Deprecated public DefaultIndexingContext(String id, String repositoryId, File repository, org.apache.lucene.store.Directory indexDirectory, String repositoryUrl, String indexUpdateUrl, List<? extends IndexCreator> indexCreators, boolean reclaimIndex) throws IOException, ExistingLuceneIndexMismatchException
public org.apache.lucene.store.Directory getIndexDirectory()
protected void setIndexDirectoryFile(File dir) throws IOException
IOException
public File getIndexDirectoryFile()
public boolean isSearchable()
IndexingContext
public void setSearchable(boolean searchable)
IndexingContext
public String getId()
IndexingContext
public void updateTimestamp() throws IOException
IOException
public void updateTimestamp(boolean save) throws IOException
IOException
public void updateTimestamp(boolean save, Date timestamp) throws IOException
IOException
public Date getTimestamp()
IndexingContext
public int getSize() throws IOException
IndexingContext
IOException
public String getRepositoryId()
IndexingContext
public File getRepository()
IndexingContext
public String getRepositoryUrl()
IndexingContext
public String getIndexUpdateUrl()
IndexingContext
public org.apache.lucene.analysis.Analyzer getAnalyzer()
IndexingContext
protected void openAndWarmup() throws IOException
IOException
protected org.apache.lucene.index.IndexWriterConfig getWriterConfig()
public org.apache.lucene.index.IndexWriter getIndexWriter() throws IOException
IndexingContext
IOException
public org.apache.lucene.search.IndexSearcher acquireIndexSearcher() throws IOException
IndexingContext
IndexSearcher
. You have to release the received instance with
IndexingContext.releaseIndexSearcher(IndexSearcher)
otherwise you are about to introduce leak.IOException
public void releaseIndexSearcher(org.apache.lucene.search.IndexSearcher is) throws IOException
IndexingContext
IndexSearcher
instance.IOException
public void commit() throws IOException
IndexingContext
IOException
public void rollback() throws IOException
IndexingContext
IOException
public void optimize() throws org.apache.lucene.index.CorruptIndexException, IOException
IndexingContext
org.apache.lucene.index.CorruptIndexException
IOException
public void close(boolean deleteFiles) throws IOException
IndexingContext
IOException
public void purge() throws IOException
IndexingContext
IOException
public void replace(org.apache.lucene.store.Directory directory) throws IOException
IndexingContext
IOException
public void replace(org.apache.lucene.store.Directory directory, Set<String> allGroups, Set<String> rootGroups) throws IOException
IOException
public void merge(org.apache.lucene.store.Directory directory) throws IOException
IndexingContext
directory
- - the directory to mergeIOException
public void merge(org.apache.lucene.store.Directory directory, DocumentFilter filter) throws IOException
IndexingContext
directory
- - the directory to mergeIOException
public GavCalculator getGavCalculator()
IndexingContext
public List<IndexCreator> getIndexCreators()
IndexingContext
public void rebuildGroups() throws IOException
IndexingContext
IOException
public Set<String> getAllGroups() throws IOException
IndexingContext
IOException
public void setAllGroups(Collection<String> groups) throws IOException
IndexingContext
IOException
public Set<String> getRootGroups() throws IOException
IndexingContext
IOException
public void setRootGroups(Collection<String> groups) throws IOException
IndexingContext
IOException
protected Set<String> getGroups(String field, String filedValue, String listField) throws IOException, org.apache.lucene.index.CorruptIndexException
IOException
org.apache.lucene.index.CorruptIndexException
protected void setGroups(Collection<String> groups, String groupField, String groupFieldValue, String groupListField) throws IOException, org.apache.lucene.index.CorruptIndexException
IOException
org.apache.lucene.index.CorruptIndexException
protected org.apache.lucene.document.Document createGroupsDocument(Collection<String> groups, String field, String fieldValue, String listField)
Copyright © 2002–2017 The Apache Software Foundation. All rights reserved.