Interface SearchEngine

  • All Known Implementing Classes:
    StandardSearchEngine

    public interface SearchEngine
    Model of a search engine with search and I/O capabilities. Various implementations can be provided, and the configuration property searchengine must qualify the concrete implementation to use.
    Since:
    6.5
    Author:
    Marco Meschieri - LogicalDOC
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      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, String[] filters, String expressionLanguage, Integer rows)
      Search for hits.
      Attention: The hits will be populated with just the fields stored in the index
      void unlock()
      This method can unlock a locked index.
    • Method Detail

      • addHit

        void addHit​(Document document,
                    String content)
             throws Exception
        Adds a new Hit into the index
        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

        void addHit​(Document document,
                    InputStream content)
             throws Exception
        Adds a new hit to the index
        Parameters:
        content - Stream of the document's file
        document - The document that we want to add
        Throws:
        Exception - is an error happens and the document cannot be added to the index
      • optimize

        void optimize()
        Launch the index optimization that physically deletes the removed entries. This is a long running operation.
      • check

        String check()
        Launch the check on the Index
        Returns:
        the output of the check
      • deleteHit

        void deleteHit​(long id)
        Deletes an hit in the index of the search engine.
        Parameters:
        id - - id of the hit
      • deleteHits

        void deleteHits​(Collection<Long> ids)
        Removed all passed hits from the index
        Parameters:
        ids - Collection of hit identifiers
      • getHit

        Hit getHit​(long id)
      • search

        Hits 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 index
        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
      • query

        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
        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
      • close

        void close()
        Closes all indexing operations, shuts down the engine.
      • unlock

        void unlock()
        This method can unlock a locked index.
      • isLocked

        boolean isLocked()
        Check if at least one index is locked
        Returns:
        true if one or more indexes are locked
      • getCount

        long getCount()
        Returns the number of indexed documents in all indexes. Used for statistical output.
        Returns:
        the total number of entries in the index
      • dropIndex

        void dropIndex()
        Drops the full-text index
      • purge

        long purge()
        Removes from the index those entries without a coutnerpart in the database
        Returns:
        number of deleted entries
      • init

        void init()
        To be called on the context startup, this method creates all indexes and unlock the existing ones
      • getServer

        Object getServer()
        Service method to get access from the internal core
        Returns:
        the search server representation