All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.craftercms.search.service.SearchService Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (C) 2007-2013 Crafter Software Corporation.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see .
 */
package org.craftercms.search.service;

import java.io.File;
import java.util.Map;

import org.craftercms.search.exception.SearchException;

/**
 * Provides a basic interface to a search engine, like Solr.
 *
 * @author Alfonso Vásquez
 * @author Dejan Brkic
 */
public interface SearchService {

    /**
     * Does a full-text search and returns a Map model.
     *
     * @param query the query object
     * @return search result in a Map data model. The key is the field name and the value is the field single value or
     *         multiple values (as a list)
     * @throws SearchException if any error occurs that makes the search fail
     */
    Map search(Query query) throws SearchException;

    /**
     * Updates the search engine's index data of an XML document.
     *
     * @param site                   the Crafter site name the content belongs to
     * @param id                     the id of the XML document, within the site
     * @param xml                    the XML document to update in the index
     * @param ignoreRootInFieldNames ignore the root element of the input XML in field names
     * @return a success string
     * @throws SearchException
     */
    String update(String site, String id, String xml, boolean ignoreRootInFieldNames) throws SearchException;

    /**
     * Deletes the search engine's index data of an XML document.
     *
     * @param site the Crafter site name the content belongs to
     * @param id   the id of the content, within the site
     * @return a success string
     * @throws SearchException
     */
    String delete(String site, String id) throws SearchException;

    /**
     * Commits any pending changes made to the search engine's index.
     *
     * @return a success string
     * @throws SearchException
     */
    String commit() throws SearchException;

    /**
     * Updates the search engine's index data of a structured document (PDF, Word, Office).
     *
     * @param site     the Crafter site name the content belongs to
     * @param id       the id of the XML document, within the site
     * @param document the document to update in the index
     * @return a success string
     * @throws SearchException
     */
    String updateDocument(String site, String id, File document) throws SearchException;

    /**
     * Updates the search engine's index data of a structured document (PDF, Word, Office).
     *
     * @param site                  the Crafter site name the content belongs to
     * @param id                    the id of the XML document, within the site
     * @param document              the document to update in the index
     * @param additionalFields      additional metadata fields to be indexed (shouldn't have the name site, id or document)
     * @return a success string
     * @throws SearchException
     */
    String updateDocument(String site, String id, File document, Map additionalFields) throws
        SearchException;

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy