Class MCRSolrIndexer

java.lang.Object
org.mycore.solr.index.MCRSolrIndexer

public class MCRSolrIndexer extends Object
Base class for indexing with solr.
Author:
shermann, Matthias Eichner
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
     
    static final int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.apache.solr.client.solrj.response.UpdateResponse
    deleteById(org.apache.solr.client.solrj.SolrClient client, String... solrIDs)
    Deletes a list of documents by unique ID.
    static org.apache.solr.client.solrj.response.UpdateResponse
    deleteDerivate(org.apache.solr.client.solrj.SolrClient solrClient, String id)
    Convenient method to delete a derivate and all its files at once.
    static org.apache.solr.client.solrj.response.UpdateResponse
    deleteOrphanedNestedDocuments(org.apache.solr.client.solrj.SolrClient solrClient)
    Deletes nested orphaned nested documents.
    static void
    dropIndex(org.apache.solr.client.solrj.SolrClient client)
    Drops the current solr index.
    static void
    dropIndexByType(String type, org.apache.solr.client.solrj.SolrClient client)
     
    static void
    optimize(org.apache.solr.client.solrj.SolrClient client)
    Sends a signal to the remote solr server to optimize its index.
    static void
    rebuildContentIndex(List<String> list, org.apache.solr.client.solrj.SolrClient solrClient)
    Rebuilds solr's content index.
    static void
    rebuildContentIndex(List<String> list, org.apache.solr.client.solrj.SolrClient solrClient, int priority)
    Rebuilds solr's content index.
    static void
    rebuildContentIndex(org.apache.solr.client.solrj.SolrClient client)
    Rebuilds solr's content index.
    static void
    rebuildMetadataIndex(String type, org.apache.solr.client.solrj.SolrClient solrClient)
    Rebuilds solr's metadata index only for objects of the given type.
    static void
    rebuildMetadataIndex(List<String> list, org.apache.solr.client.solrj.SolrClient solrClient)
    Rebuilds solr's metadata index.
    static void
    rebuildMetadataIndex(org.apache.solr.client.solrj.SolrClient solrClient)
    Rebuilds solr's metadata index.
    static void
    Submits a index handler to the executor service (execute as a thread) with the given priority.
    static void
    submitIndexHandler(MCRSolrIndexHandler indexHandler, int priority)
    Submits a index handler to the executor service (execute as a thread) with the given priority.
    static void
    synchronizeMetadataIndex(org.apache.solr.client.solrj.SolrClient client)
    Synchronizes the solr server with the database.
    static void
    synchronizeMetadataIndex(org.apache.solr.client.solrj.SolrClient client, String objectType)
    Synchronizes the solr server with the mycore store for a given object type.
    protected static boolean
    Checks if the application uses nested documents.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • MCRSolrIndexer

      public MCRSolrIndexer()
  • Method Details

    • deleteOrphanedNestedDocuments

      public static org.apache.solr.client.solrj.response.UpdateResponse deleteOrphanedNestedDocuments(org.apache.solr.client.solrj.SolrClient solrClient) throws org.apache.solr.client.solrj.SolrServerException, IOException
      Deletes nested orphaned nested documents. https://issues.apache.org/jira/browse/SOLR-6357
      Returns:
      the response or null if MCRSolrUtils.useNestedDocuments() returns false
      Throws:
      org.apache.solr.client.solrj.SolrServerException - solr server exception
      IOException - io exception
    • deleteById

      public static org.apache.solr.client.solrj.response.UpdateResponse deleteById(org.apache.solr.client.solrj.SolrClient client, String... solrIDs)
      Deletes a list of documents by unique ID. Also removes any nested document of that ID.
      Parameters:
      solrIDs - the list of solr document IDs to delete
    • deleteDerivate

      public static org.apache.solr.client.solrj.response.UpdateResponse deleteDerivate(org.apache.solr.client.solrj.SolrClient solrClient, String id)
      Convenient method to delete a derivate and all its files at once.
      Parameters:
      id - the derivate id
      Returns:
      the solr response
    • useNestedDocuments

      protected static boolean useNestedDocuments()
      Checks if the application uses nested documents. Using nested documents requires additional queries and slows performance.
      Returns:
      true if nested documents are used, otherwise false
    • rebuildMetadataIndex

      public static void rebuildMetadataIndex(org.apache.solr.client.solrj.SolrClient solrClient)
      Rebuilds solr's metadata index.
    • rebuildMetadataIndex

      public static void rebuildMetadataIndex(String type, org.apache.solr.client.solrj.SolrClient solrClient)
      Rebuilds solr's metadata index only for objects of the given type.
      Parameters:
      type - of the objects to index
    • rebuildMetadataIndex

      public static void rebuildMetadataIndex(List<String> list, org.apache.solr.client.solrj.SolrClient solrClient)
      Rebuilds solr's metadata index.
      Parameters:
      list - list of identifiers of the objects to index
      solrClient - solr server to index
    • rebuildContentIndex

      public static void rebuildContentIndex(org.apache.solr.client.solrj.SolrClient client)
      Rebuilds solr's content index.
    • rebuildContentIndex

      public static void rebuildContentIndex(List<String> list, org.apache.solr.client.solrj.SolrClient solrClient)
      Rebuilds solr's content index.
      Parameters:
      solrClient - solr client connection
      list - list of mycore object id's
    • rebuildContentIndex

      public static void rebuildContentIndex(List<String> list, org.apache.solr.client.solrj.SolrClient solrClient, int priority)
      Rebuilds solr's content index.
      Parameters:
      solrClient - solr client connection
      list - list of mycore object id's
      priority - higher priority means earlier execution
    • submitIndexHandler

      public static void submitIndexHandler(MCRSolrIndexHandler indexHandler)
      Submits a index handler to the executor service (execute as a thread) with the given priority.
      Parameters:
      indexHandler - index handler to submit
    • submitIndexHandler

      public static void submitIndexHandler(MCRSolrIndexHandler indexHandler, int priority)
      Submits a index handler to the executor service (execute as a thread) with the given priority.
      Parameters:
      indexHandler - index handler to submit
      priority - higher priority means earlier execution
    • dropIndex

      public static void dropIndex(org.apache.solr.client.solrj.SolrClient client) throws Exception
      Drops the current solr index.
      Throws:
      Exception
    • dropIndexByType

      public static void dropIndexByType(String type, org.apache.solr.client.solrj.SolrClient client) throws Exception
      Throws:
      Exception
    • optimize

      public static void optimize(org.apache.solr.client.solrj.SolrClient client)
      Sends a signal to the remote solr server to optimize its index.
    • synchronizeMetadataIndex

      public static void synchronizeMetadataIndex(org.apache.solr.client.solrj.SolrClient client) throws IOException, org.apache.solr.client.solrj.SolrServerException
      Synchronizes the solr server with the database. As a result the solr server contains the same documents as the database. All solr zombie documents will be removed, and all not indexed mycore objects will be indexed.
      Throws:
      IOException
      org.apache.solr.client.solrj.SolrServerException
    • synchronizeMetadataIndex

      public static void synchronizeMetadataIndex(org.apache.solr.client.solrj.SolrClient client, String objectType) throws IOException, org.apache.solr.client.solrj.SolrServerException
      Synchronizes the solr server with the mycore store for a given object type. As a result the solr server contains the same documents as the store. All solr zombie documents will be removed, and all not indexed mycore objects will be indexed.
      Throws:
      IOException
      org.apache.solr.client.solrj.SolrServerException