Package com.logicaldoc.core.searchengine
Class StandardSearchEngine
- java.lang.Object
-
- com.logicaldoc.core.searchengine.StandardSearchEngine
-
- All Implemented Interfaces:
SearchEngine
public class StandardSearchEngine extends Object implements SearchEngine
Standard implementation that implements a local search engine- Since:
- 6.5
- Author:
- Marco Meschieri - LogicalDOC
-
-
Field Summary
Fields Modifier and Type Field Description static org.apache.lucene.util.Version
VERSION
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addHit(Document document, InputStream content)
Adds a new hit to the indexvoid
addHit(Document document, String content)
Adds a new Hit into the indexString
check()
Launch the check on the Indexvoid
close()
Closes all indexing operations, shuts down the engine.void
deleteHit(long id)
Deletes an hit in the index of the search engine.void
deleteHits(Collection<Long> ids)
Removed all passed hits from the indexvoid
dropIndex()
Drops the full-text indexlong
getCount()
Returns the number of indexed documents in all indexes.Hit
getHit(long id)
Object
getServer()
Service method to get access from the internal corevoid
init()
To be called on the context startup, this method creates all indexes and unlock the existing onesboolean
isLocked()
Check if at least one index is lockedvoid
optimize()
Launch the index optimization and triggers the build of spellcheck dictionaryHits
search(String expression, String[] filters, String expressionLanguage, Integer rows)
Search for hits.
Attention: The hits will be populated with just the fields stored in the indexvoid
setConfig(ContextProperties config)
void
setDocumentDao(DocumentDAO documentDao)
void
setNoteDao(DocumentNoteDAO noteDao)
void
unlock()
This method can unlock a locked index.
-
-
-
Method Detail
-
setConfig
public void setConfig(ContextProperties config)
-
setDocumentDao
public void setDocumentDao(DocumentDAO documentDao)
-
addHit
public void addHit(Document document, String content) throws Exception
Description copied from interface:SearchEngine
Adds a new Hit into the index- Specified by:
addHit
in interfaceSearchEngine
- Parameters:
document
- The document to add into the indexcontent
- The extracted body text- Throws:
Exception
- is an error happens and the document cannot be added to the index
-
addHit
public void addHit(Document document, InputStream content) throws Exception
Description copied from interface:SearchEngine
Adds a new hit to the index- Specified by:
addHit
in interfaceSearchEngine
- Parameters:
document
- The document that we want to addcontent
- Stream of the document's file- Throws:
Exception
- is an error happens and the document cannot be added to the index
-
optimize
public void optimize()
Description copied from interface:SearchEngine
Launch the index optimization and triggers the build of spellcheck dictionary- Specified by:
optimize
in interfaceSearchEngine
-
check
public String check()
Description copied from interface:SearchEngine
Launch the check on the Index- Specified by:
check
in interfaceSearchEngine
- Returns:
- the output of the check
-
deleteHit
public void deleteHit(long id)
Description copied from interface:SearchEngine
Deletes an hit in the index of the search engine.- Specified by:
deleteHit
in interfaceSearchEngine
- Parameters:
id
- - id of the hit
-
deleteHits
public void deleteHits(Collection<Long> ids)
Description copied from interface:SearchEngine
Removed all passed hits from the index- Specified by:
deleteHits
in interfaceSearchEngine
- Parameters:
ids
- Collection of hit identifiers
-
getHit
public Hit getHit(long id)
- Specified by:
getHit
in interfaceSearchEngine
-
search
public Hits search(String expression, String[] filters, String expressionLanguage, Integer rows)
Description copied from interface:SearchEngine
Search for hits.
Attention: The hits will be populated with just the fields stored in the index- Specified by:
search
in interfaceSearchEngine
- Parameters:
expression
- the search expressionfilters
- a set of filter expressions, optionalexpressionLanguage
- the language in which theexpression
is writtedrows
- maximum number elements to be returned- Returns:
- the hits
-
close
public void close()
Description copied from interface:SearchEngine
Closes all indexing operations, shuts down the engine.- Specified by:
close
in interfaceSearchEngine
-
unlock
public void unlock()
Description copied from interface:SearchEngine
This method can unlock a locked index.- Specified by:
unlock
in interfaceSearchEngine
-
isLocked
public boolean isLocked()
Description copied from interface:SearchEngine
Check if at least one index is locked- Specified by:
isLocked
in interfaceSearchEngine
- Returns:
- true if one or more indexes are locked
-
getCount
public long getCount()
Description copied from interface:SearchEngine
Returns the number of indexed documents in all indexes. Used for statistical output.- Specified by:
getCount
in interfaceSearchEngine
- Returns:
- the total number of entries in the index
- See Also:
SearchEngine.getCount()
-
dropIndex
public void dropIndex()
Description copied from interface:SearchEngine
Drops the full-text index- Specified by:
dropIndex
in interfaceSearchEngine
- See Also:
SearchEngine.dropIndex()
-
init
public void init()
Description copied from interface:SearchEngine
To be called on the context startup, this method creates all indexes and unlock the existing ones- Specified by:
init
in interfaceSearchEngine
- See Also:
SearchEngine.init()
-
getServer
public Object getServer()
Description copied from interface:SearchEngine
Service method to get access from the internal core- Specified by:
getServer
in interfaceSearchEngine
- Returns:
- the search server representation
-
setNoteDao
public void setNoteDao(DocumentNoteDAO noteDao)
-
-