001/* 002 * Copyright 2026 Anyware Services 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 */ 016package org.ametys.cms.indexing.solr; 017 018import java.util.Collection; 019import java.util.List; 020 021import org.apache.solr.common.SolrInputDocument; 022 023import org.ametys.cms.search.query.Query; 024import org.ametys.cms.search.solr.schema.SchemaDefinition; 025import org.ametys.plugins.repository.AmetysObject; 026 027/** 028 * Index additional items on already indexed object (content, resources...). 029 */ 030public interface AdditionalDataIndexer 031{ 032 /** Type identifier for content additional data indexers */ 033 public static final String TYPE_CONTENT = "content"; 034 /** Type identifier for resource additional data indexers */ 035 public static final String TYPE_RESOURCE = "resource"; 036 /** Type identifier for trash elements additional data indexers */ 037 public static final String TYPE_TRASH_ELEMENT = "trashelement"; 038 039 /** 040 * Get the object/document types supported by this indexer. 041 * @return The object or document types supported by this indexer. 042 */ 043 Collection<String> getSupportedTypes(); 044 045 /** 046 * Index additional object properties in the corresponding document. 047 * @param object The object to index. 048 * @param document The destination document. 049 * @return Additional documents to index (can be empty). 050 */ 051 List<SolrInputDocument> indexAdditionalDocuments(AmetysObject object, SolrInputDocument document); 052 053 /** 054 * The list of Solr queries that returns the documents to delete when unindexing the given ametys object 055 * @param ametysObjectId The id of the ametys object to unindex 056 * @return The list of Solr queries that returns the documents to delete 057 * @throws Exception If an error occurs while building the queries 058 */ 059 List<Query> getUnindexObjectQuery(String ametysObjectId) throws Exception; 060 061 /** 062 * The solr query that returns the documents to delete when unindexing all items of the given type 063 * @param type The type of the items to unindex 064 * @return The solr query that returns the documents to delete. Can be null 065 * @throws Exception If an error occurs while building the queries 066 */ 067 Query getUnindexAllQuery(String type) throws Exception; 068 069 /** 070 * Get the schema definitions used by this indexer. 071 * @return The schema definitions used by this indexer. 072 */ 073 Collection<SchemaDefinition> getSchemaDefinitions(); 074}