Class 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 Detail

      • VERSION

        public static org.apache.lucene.util.Version VERSION
    • Method Detail

      • 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 interface SearchEngine
        Parameters:
        document - The document to add into the index
        content - 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 interface SearchEngine
        Parameters:
        document - The document that we want to add
        content - 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 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
      • 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
        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,
                           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
      • close

        public void close()
        Description copied from interface: SearchEngine
        Closes all indexing operations, shuts down the engine.
        Specified by:
        close in interface SearchEngine
      • 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
      • 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 interface SearchEngine
        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 interface SearchEngine
        Returns:
        the search server representation