class ComponentIndexer extends IndexManager implements ObjectIndexer<ComponentDocument> {

    private static final Logger LOGGER = Logger.getLogger(ComponentIndexer.class);
    private static final ComponentIndexer INSTANCE = new ComponentIndexer();

    static ComponentIndexer getInstance() {
        return INSTANCE;
    }

    /**
     * Private constructor.
     */
    private ComponentIndexer() {
        super(IndexType.COMPONENT);
    }

    @Override
    public String[] getSearchFields() {
        return IndexConstants.COMPONENT_SEARCH_FIELDS;
    }

    /**
     * Adds a Component object to a Lucene index.
     *
     * @param component A persisted Component object.
     */
    public void add(final ComponentDocument component) {
        final Document doc = convertToDocument(component);
        addDocument(doc);
    }

    @Override
    public void update(ComponentDocument component) {
        final Term term = convertToTerm(component);
        final Document doc = convertToDocument(component);
        updateDocument(term, doc);
    }

    /**
     * Deletes a Component object from the Lucene index.
     *
     * @param component A persisted Component object.
     */
    public void remove(final ComponentDocument component) {
        final Term term = convertToTerm(component);
        deleteDocuments(term);
    }

    /**
     * Re-indexes all Component objects.
     * @since 3.4.0
     */
    public void reindex() {<FILL_FUNCTION_BODY>}

    private static List<ComponentDocument> fetchNext(final QueryManager qm, final Long lastId) {
        final Query<Component> query = qm.getPersistenceManager().newQuery(Component.class);
        var filterParts = new ArrayList<String>();
        var params = new HashMap<String, Object>();
        filterParts.add("(project.active == null || project.active)");
        if (lastId != null) {
            filterParts.add("id > :lastId");
            params.put("lastId", lastId);
        }
        query.setFilter(String.join(" && ", filterParts));
        query.setNamedParameters(params);
        query.setOrdering("id ASC");
        query.setRange(0, 1000);
        query.setResult("id, uuid, \"group\", name, version, description, sha1");
        try {
            return List.copyOf(query.executeResultList(ComponentDocument.class));
        } finally {
            query.closeAll();
        }
    }

    private Document convertToDocument(final ComponentDocument component) {
        final var doc = new Document();
        addField(doc, IndexConstants.COMPONENT_UUID, component.uuid().toString(), Field.Store.YES, false);
        addField(doc, IndexConstants.COMPONENT_NAME, component.name(), Field.Store.YES, true);
        addField(doc, IndexConstants.COMPONENT_GROUP, component.group(), Field.Store.YES, true);
        addField(doc, IndexConstants.COMPONENT_VERSION, component.version(), Field.Store.YES, false);
        addField(doc, IndexConstants.COMPONENT_SHA1, component.sha1(), Field.Store.YES, true);
        addField(doc, IndexConstants.COMPONENT_DESCRIPTION, component.description(), Field.Store.YES, true);
        return doc;
    }

    private static Term convertToTerm(final ComponentDocument component) {
        return new Term(IndexConstants.COMPONENT_UUID, component.uuid().toString());
    }

}

        LOGGER.info("Starting reindex task. This may take some time.");
        super.reindex();

        long docsIndexed = 0;
        final long startTimeNs = System.nanoTime();
        try (final QueryManager qm = new QueryManager()) {
            List<ComponentDocument> docs = fetchNext(qm, null);
            while (!docs.isEmpty()) {
                docs.forEach(this::add);
                docsIndexed += docs.size();
                commit();

                docs = fetchNext(qm, docs.get(docs.size() - 1).id());
            }
        }
        LOGGER.info("Reindexing of %d components completed in %s"
                .formatted(docsIndexed, Duration.ofNanos(System.nanoTime() - startTimeNs)));
    
<methods>public void addDocument(Document) ,public static void checkIndexesConsistency() ,public void close() ,public void commit() ,public static void delete(org.dependencytrack.search.IndexManager.IndexType) ,public void deleteDocuments(Term) ,public static void ensureIndexesExists() ,public org.dependencytrack.search.IndexManager.IndexType getIndexType() ,public java.lang.String[] getSearchFields() ,public void reindex() ,public void updateDocument(Term, Document) <variables>private static final Logger LOGGER,private final non-sealed Counter addOperationCounter,private final non-sealed Counter commitOperationCounter,private final non-sealed Counter deleteOperationCounter,private Gauge docsRamTotalGauge,private final non-sealed Tag indexTag,private final non-sealed org.dependencytrack.search.IndexManager.IndexType indexType,private IndexWriter iwriter,private final non-sealed Logger logger,private Gauge numDocsGauge,private Gauge ramBytesUsedGauge,private DirectoryReader searchReader,private final non-sealed Counter updateOperationCounter