001/*
002 * The contents of this file are subject to the license and copyright
003 * detailed in the LICENSE and NOTICE files at the root of the source
004 * tree.
005 */
006package org.fcrepo.search.api;
007
008import org.fcrepo.kernel.api.Transaction;
009import org.fcrepo.kernel.api.identifiers.FedoraId;
010import org.fcrepo.kernel.api.models.ResourceHeaders;
011
012/**
013 * An interface defining search index management operations
014 *
015 * @author dbernstein
016 */
017public interface SearchIndex {
018
019    /**
020     * Adds or updates the index with the resource header information.
021     * @param transaction The externally generated transaction.
022     * @param resourceHeaders The resource headers associated with the resource
023     */
024    void addUpdateIndex(Transaction transaction, ResourceHeaders resourceHeaders);
025
026    /**
027     * Removes indexed fields associated with the specified Fedora ID
028     *
029     * @param transaction The transaction
030     * @param fedoraId    The Fedora ID
031     */
032    void removeFromIndex(Transaction transaction, FedoraId fedoraId);
033
034    /**
035     * Performs a search based on the parameters and returns the result.
036     *
037     * @param parameters The parameters defining the search
038     * @return The result of the search
039     */
040    SearchResult doSearch(SearchParameters parameters) throws InvalidQueryException;
041
042    /**
043     * Remove all persistent state associated with the index.
044     */
045    void reset();
046
047    /**
048     * Commit the changes made in the transaction.
049     *
050     * @param tx The transaction .
051     */
052    void commitTransaction(final Transaction tx);
053
054    /**
055     * Rollback the changes in the transaction.
056     *
057     * @param tx The transaction.
058     */
059    void rollbackTransaction(final Transaction tx);
060
061    /**
062     * Clear all transactions in the search index.
063     */
064    void clearAllTransactions();
065}