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.VersionVERSION
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddHit(Document document, InputStream content)Adds a new hit to the indexvoidaddHit(Document document, String content)Adds a new Hit into the indexStringcheck()Launch the check on the Indexvoidclose()Closes all indexing operations, shuts down the engine.voiddeleteHit(long id)Deletes an hit in the index of the search engine.voiddeleteHits(Collection<Long> ids)Removed all passed hits from the indexvoiddropIndex()Drops the full-text indexlonggetCount()Returns the number of indexed documents in all indexes.HitgetHit(long id)ObjectgetServer()Service method to get access from the internal corevoidinit()To be called on the context startup, this method creates all indexes and unlock the existing onesbooleanisLocked()Check if at least one index is lockedvoidoptimize()Launch the index optimization that physically deletes the removed entries.longpurge()Removes from the index those entries without a coutnerpart in the databaseHitsquery(String expression, int page, int size)Executes a low-level query in the fulltext index
Attention: The hits will be populated with just the fields stored in the indexHitssearch(String expression, String[] filters, String expressionLanguage, Integer rows)Search for hits.
Attention: The hits will be populated with just the fields stored in the indexvoidsetConfig(ContextProperties config)voidsetDocumentDao(DocumentDAO documentDao)voidsetNoteDao(DocumentNoteDAO noteDao)voidunlock()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:SearchEngineAdds a new Hit into the index- Specified by:
addHitin 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:SearchEngineAdds a new hit to the index- Specified by:
addHitin 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:SearchEngineLaunch the index optimization that physically deletes the removed entries. This is a long running operation.- Specified by:
optimizein interfaceSearchEngine
-
check
public String check()
Description copied from interface:SearchEngineLaunch the check on the Index- Specified by:
checkin interfaceSearchEngine- Returns:
- the output of the check
-
deleteHit
public void deleteHit(long id)
Description copied from interface:SearchEngineDeletes an hit in the index of the search engine.- Specified by:
deleteHitin interfaceSearchEngine- Parameters:
id- - id of the hit
-
deleteHits
public void deleteHits(Collection<Long> ids)
Description copied from interface:SearchEngineRemoved all passed hits from the index- Specified by:
deleteHitsin interfaceSearchEngine- Parameters:
ids- Collection of hit identifiers
-
getHit
public Hit getHit(long id)
- Specified by:
getHitin interfaceSearchEngine
-
query
public Hits query(String expression, int page, int size)
Description copied from interface:SearchEngineExecutes a low-level query in the fulltext index
Attention: The hits will be populated with just the fields stored in the index- Specified by:
queryin interfaceSearchEngine- Parameters:
expression- the query to usepage- the page to retrievesize- the maximum number of entries to retrieve- Returns:
- the search result, ordered by ascending id
-
search
public Hits search(String expression, String[] filters, String expressionLanguage, Integer rows)
Description copied from interface:SearchEngineSearch for hits.
Attention: The hits will be populated with just the fields stored in the index- Specified by:
searchin interfaceSearchEngine- Parameters:
expression- the search expressionfilters- a set of filter expressions, optionalexpressionLanguage- the language in which theexpressionis writtedrows- maximum number elements to be returned- Returns:
- the hits ordered by descending score
-
close
public void close()
Description copied from interface:SearchEngineCloses all indexing operations, shuts down the engine.- Specified by:
closein interfaceSearchEngine
-
unlock
public void unlock()
Description copied from interface:SearchEngineThis method can unlock a locked index.- Specified by:
unlockin interfaceSearchEngine
-
isLocked
public boolean isLocked()
Description copied from interface:SearchEngineCheck if at least one index is locked- Specified by:
isLockedin interfaceSearchEngine- Returns:
- true if one or more indexes are locked
-
getCount
public long getCount()
Description copied from interface:SearchEngineReturns the number of indexed documents in all indexes. Used for statistical output.- Specified by:
getCountin interfaceSearchEngine- Returns:
- the total number of entries in the index
- See Also:
SearchEngine.getCount()
-
purge
public long purge()
Description copied from interface:SearchEngineRemoves from the index those entries without a coutnerpart in the database- Specified by:
purgein interfaceSearchEngine- Returns:
- number of deleted entries
-
dropIndex
public void dropIndex()
Description copied from interface:SearchEngineDrops the full-text index- Specified by:
dropIndexin interfaceSearchEngine- See Also:
SearchEngine.dropIndex()
-
init
public void init()
Description copied from interface:SearchEngineTo be called on the context startup, this method creates all indexes and unlock the existing ones- Specified by:
initin interfaceSearchEngine- See Also:
SearchEngine.init()
-
getServer
public Object getServer()
Description copied from interface:SearchEngineService method to get access from the internal core- Specified by:
getServerin interfaceSearchEngine- Returns:
- the search server representation
-
setNoteDao
public void setNoteDao(DocumentNoteDAO noteDao)
-
-