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 final org.apache.lucene.util.Version`
`VERSION`

## Method Summary

Modifier and Type
Method
Description
`void`
`addHit(Document document, InputStream content)`
Adds a new hit to the index
`void`
`addHit(Document document, String content)`
Adds a new Hit into the index
`String`
`check()`
Launch the check on the Index
`void`
`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 index
`void`
`dropIndex()`
Drops the full-text index
`long`
`getCount()`
Returns the number of indexed documents in all indexes.
`Hit`
`getHit(long id)`
`Object`
`getServer()`
Service method to get access from the internal core
`void`
`init()`
To be called on the context startup, this method creates all indexes and unlock the existing ones
`boolean`
`isLocked()`
Check if at least one index is locked
`void`
`optimize()`
Launch the index optimization that physically deletes the removed entries.
`long`
`purge()`
Removes from the index those entries without a coutnerpart in the database
`Hits`
`query(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 index
`Hits`
`search(String expression, Set<String> filters, String expressionLanguage, Integer rows)`
Search for hits.
Attention: The hits will be populated with just the fields stored in the index
`void`
`setConfig(ContextProperties config)`
`void`
`setDocumentDao(DocumentDAO documentDao)`
`void`
`setNoteDao(DocumentNoteDAO noteDao)`
`void`
`unlock()`
This method can unlock a locked index.

### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### VERSION

public static final org.apache.lucene.util.Version VERSION

## Method Details

### setConfig

public void setConfig(ContextProperties config)

### setDocumentDao

public void setDocumentDao(DocumentDAO documentDao)

### addHit

public void addHit(Document document, String content) throws IndexException
Description copied from interface: `SearchEngine`
Adds a new Hit into the index

Specified by:
  `addHit` in interface `SearchEngine`
Parameters:
  `document` - The document to add into the index
  `content` - The extracted body text
Throws:
  `IndexException` - is an error happens and the document cannot be added to the index

### addHit

public void addHit(Document document, InputStream content) throws IndexException
Description copied from interface: `SearchEngine`
Adds a new hit to the index

Specified by:
  `addHit` in interface `SearchEngine`
Parameters:
  `document` - The document that we want to add
  `content` - Stream of the document's file
Throws:
  `IndexException` - 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 that physically deletes the removed entries. This is a long running operation.

Specified by:
  `optimize` in interface `SearchEngine`

### check

public String check()
Description copied from interface: `SearchEngine`
Launch the check on the Index

Specified by:
  `check` in interface `SearchEngine`
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 interface `SearchEngine`
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 interface `SearchEngine`
Parameters:
  `ids` - Collection of hit identifiers

### getHit

public Hit getHit(long id)

Specified by:
  `getHit` in interface `SearchEngine`

### query

public Hits query(String expression, int page, int size)
Description copied from interface: `SearchEngine`
Executes a low-level query in the fulltext index
Attention: The hits will be populated with just the fields stored in the index

Specified by:
  `query` in interface `SearchEngine`
Parameters:
  `expression` - the query to use
  `page` - the page to retrieve
  `size` - the maximum number of entries to retrieve
Returns:
  the search result, ordered by ascending id

### search

public Hits search(String expression, Set<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 interface `SearchEngine`
Parameters:
  `expression` - the search expression
  `filters` - a set of filter expressions, optional
  `expressionLanguage` - the language in which the `expression` is writted
  `rows` - maximum number elements to be returned
Returns:
  the hits ordered by descending score

### unlock

public void unlock()
Description copied from interface: `SearchEngine`
This method can unlock a locked index.

Specified by:
  `unlock` in interface `SearchEngine`

### isLocked

public boolean isLocked()
Description copied from interface: `SearchEngine`
Check if at least one index is locked

Specified by:
  `isLocked` in interface `SearchEngine`
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 interface `SearchEngine`
Returns:
  the total number of entries in the index
See Also:
  - `SearchEngine.getCount()`

### purge

public long purge()
Description copied from interface: `SearchEngine`
Removes from the index those entries without a coutnerpart in the database

Specified by:
  `purge` in interface `SearchEngine`
Returns:
  number of deleted entries

### dropIndex

public void dropIndex()
Description copied from interface: `SearchEngine`
Drops the full-text index

Specified by:
  `dropIndex` in interface `SearchEngine`
See Also:
  - `SearchEngine.dropIndex()`

### close

@PreDestroy public void close()
Description copied from interface: `SearchEngine`
Closes all indexing operations, shuts down the engine.

Specified by:
  `close` in interface `SearchEngine`

### init

@PostConstruct 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 interface `SearchEngine`

### getServer

public Object getServer()
Description copied from interface: `SearchEngine`
Service method to get access from the internal core

Specified by:
  `getServer` in interface `SearchEngine`
Returns:
  the search server representation

### setNoteDao

public void setNoteDao(DocumentNoteDAO noteDao)