001/*
002 * (C) Copyright 2014 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     tdelprat
018 *     bdelbosc
019 */
020
021package org.nuxeo.elasticsearch.api;
022
023import java.util.List;
024
025import org.nuxeo.elasticsearch.commands.IndexingCommand;
026
027/**
028 * Interface to process indexing of documents
029 *
030 * @since 5.9.3
031 */
032public interface ElasticSearchIndexing {
033
034    /**
035     * Run a worker to process the {@link IndexingCommand}.
036     * <p>
037     * Asynchronous command schedules an indexing job and return.
038     * </p>
039     * <p>
040     * Synchronous command execute an indexing job using a new Tx then refresh the index so the document is searchable
041     * immediately. if the command is also recursive the children are processed asynchronously.
042     * </p>
043     * <p>
044     * If there is more than one cmd the elasticsearch request is done in bulk mode.
045     * </p>
046     *
047     * @since 7.1
048     */
049    void runIndexingWorker(List<IndexingCommand> cmds);
050
051    /**
052     * Reindex documents matching the NXQL query, This is done in an asynchronous job.
053     *
054     * @since 7.1
055     */
056    void runReindexingWorker(String repositoryName, String nxql);
057
058    /**
059     * Process the {@link IndexingCommand}.
060     * <p>
061     * Send indexing command to Elasticsearch, if the command is synchronous the index is refreshed so the document is
062     * searchable immediately. Recursive indexing is not taken in account except for deletion. This is not a
063     * transactional operation, a rollback will not discard the executed commands.
064     * </p>
065     *
066     * @since 7.1
067     */
068    void indexNonRecursive(IndexingCommand cmd);
069
070    /**
071     * Same as {@link ElasticSearchIndexing#indexNonRecursive(org.nuxeo.elasticsearch.commands.IndexingCommand)} but
072     * process the list command using a bulk request.</p>
073     *
074     * @since 7.1
075     */
076    void indexNonRecursive(List<IndexingCommand> cmds);
077
078}