public class LuceneSearchIndexer extends AbstractSearchIndexer
SearchIndexer
using lucene as
underlying search-engine.Modifier and Type | Field and Description |
---|---|
private int |
addCounter
|
private LuceneFieldManager |
fieldManager
The
LuceneFieldManager . |
private org.apache.lucene.index.IndexWriter |
indexWriter
The
IndexWriter . |
private SearchDependencies |
searchDependencies
The
SearchDependencies . |
private ManagedSearchEngine |
searchEngine |
private LuceneSearchEngineBuilder |
searchEngineBuilder |
private long |
sessionId
The base-ID for this session.
|
Constructor and Description |
---|
LuceneSearchIndexer(org.apache.lucene.index.IndexWriter indexWriter,
LuceneSearchEngineBuilder searchEngineBuilder,
LuceneFieldManager fieldManager,
SearchDependencies searchDependencies)
The constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
add(MutableSearchEntry entry)
This method adds the given
entry to the search-index. |
protected void |
add(MutableSearchEntry entry,
Long id) |
void |
close()
This method closes the search index.
|
MutableSearchEntry |
createEntry()
This method creates a new and empty entry for the search-index.
|
void |
flush()
This method flushes the search index what ensures that all changes are
written to the index.
|
protected org.apache.lucene.index.IndexWriter |
getIndexWriter()
This method gets the
IndexWriter . |
SearchEngine |
getSearchEngine()
This method gets the
SearchEngine for the index of this
SearchIndexer . |
void |
optimize()
This method optimizes the search index.
|
int |
remove(String field,
Object value)
This method removes all
existing entries
identified by the given value at the given
property from the search-index. |
protected int |
remove(org.apache.lucene.index.Term term)
This method performs the actual remove by
Term . |
remove, remove, removeByCustumId, removeById, removeByUri, search, update
getLogger
private final LuceneSearchEngineBuilder searchEngineBuilder
getSearchEngine()
private final LuceneFieldManager fieldManager
LuceneFieldManager
.private final SearchDependencies searchDependencies
SearchDependencies
.createEntry()
private final long sessionId
addCounter
to create
IDs
.private int addCounter
private org.apache.lucene.index.IndexWriter indexWriter
IndexWriter
.private ManagedSearchEngine searchEngine
getSearchEngine()
public LuceneSearchIndexer(org.apache.lucene.index.IndexWriter indexWriter, LuceneSearchEngineBuilder searchEngineBuilder, LuceneFieldManager fieldManager, SearchDependencies searchDependencies)
indexWriter
- is the index modifier to use.searchEngineBuilder
- is the LuceneSearchEngineBuilder
required for
getSearchEngine()
.fieldManager
- is the LuceneFieldManager
.searchDependencies
- are the SearchDependencies
.protected org.apache.lucene.index.IndexWriter getIndexWriter()
IndexWriter
.IndexWriter
.public void add(MutableSearchEntry entry) throws SearchException
entry
to the search-index.entry
- is the entry to add.SearchException
- if the operation failed.protected void add(MutableSearchEntry entry, Long id) throws SearchException
add
in class AbstractSearchIndexer
entry
- is the MutableSearchEntry
to add.id
- is the ID
for the
entry
.SearchException
SearchIndexer.add(MutableSearchEntry)
public void close()
public void flush() throws SearchException
SearchException
- if the operation failed.public MutableSearchEntry createEntry()
filled
with
data, use SearchIndexer.add(MutableSearchEntry)
to add it to the search index.public void optimize() throws SearchException
searches
.SearchException
- if the operation failed.protected int remove(org.apache.lucene.index.Term term)
Term
.term
- is the Term
identifying the entry/entries
to remove.entries
.AbstractSearchIndexer.removeByCustumId(String)
,
AbstractSearchIndexer.removeByUri(String, String)
,
IndexWriter.deleteDocuments(Term)
public int remove(String field, Object value) throws SearchException
existing
entries
identified by the given value
at the given
property
from the search-index. field
- is the name of the
field
where the value
is expected to occur. Therefore
the field should NOT to be of the
type
SearchFieldType.TEXT
.value
- is the
value
of the field.-1
if
the number is unknown because this is not supported by the
implementation.SearchException
- if the operation failed.public SearchEngine getSearchEngine()
SearchEngine
for the index of this
SearchIndexer
. It may be used for advanced indexing where
search-queries need to performed for updating the search-index.SearchEngine
.Copyright © 2001–2016 mmm-Team. All rights reserved.