Package org.mycore.solr.classification
Class MCRSolrClassificationUtil
java.lang.Object
org.mycore.solr.classification.MCRSolrClassificationUtil
Some solr classification utility stuff.
- Author:
- Matthias Eichner
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
bulkIndex
(org.apache.solr.client.solrj.SolrClient client, List<org.apache.solr.common.SolrInputDocument> solrDocumentList) Async bulk index.static void
Drops the whole solr classification index.static String
encodeCategoryId
(MCRCategoryID classId) Encodes the mycore category id to a solr usable one.static Collection<MCRCategoryID>
fromString
(Collection<String> categoryIds) Returns a collection of category id instances.static LinkedList<MCRCategory>
getAncestors
(MCRCategory category) Returns a list of all ancestors.static MCRSolrCore
getCore()
Returns the solr classification core.static List<MCRCategory>
getDescendants
(MCRCategory category) Returns a list of all descendants.static void
Reindex the whole classification system with the default classification solr core.static void
rebuildIndex
(org.apache.solr.client.solrj.SolrClient client) Reindex the whole classification system.static void
reindex
(Collection<MCRCategoryID> categoryIds) static void
reindex
(MCRCategory... categories) Reindex a bunch ofMCRCategory
.static List<org.apache.solr.common.SolrInputDocument>
toSolrDocument
(Collection<MCRCategory> categoryList) Creates a new list ofSolrInputDocument
based on the given category list.static List<org.apache.solr.common.SolrInputDocument>
toSolrDocument
(MCRCategLinkReference linkReference, Collection<MCRCategoryID> categories) Creates a new list ofSolrInputDocument
based on the given categories and the link.
-
Constructor Details
-
MCRSolrClassificationUtil
public MCRSolrClassificationUtil()
-
-
Method Details
-
rebuildIndex
public static void rebuildIndex()Reindex the whole classification system with the default classification solr core. -
rebuildIndex
public static void rebuildIndex(org.apache.solr.client.solrj.SolrClient client) Reindex the whole classification system.- Parameters:
client
- the target solr client
-
bulkIndex
public static void bulkIndex(org.apache.solr.client.solrj.SolrClient client, List<org.apache.solr.common.SolrInputDocument> solrDocumentList) Async bulk index. The collection is split into parts of one thousand.- Parameters:
solrDocumentList
- the list to index
-
dropIndex
public static void dropIndex()Drops the whole solr classification index. -
getDescendants
Returns a list of all descendants. The list is unordered.- Returns:
- list of descendants.
-
getAncestors
Returns a list of all ancestors. The list is ordered. The first element is always the root node and the last element is always the parent. If the element has no ancestor an empty list is returned.- Returns:
- list of ancestors
-
toSolrDocument
public static List<org.apache.solr.common.SolrInputDocument> toSolrDocument(Collection<MCRCategory> categoryList) Creates a new list ofSolrInputDocument
based on the given category list. -
toSolrDocument
public static List<org.apache.solr.common.SolrInputDocument> toSolrDocument(MCRCategLinkReference linkReference, Collection<MCRCategoryID> categories) Creates a new list ofSolrInputDocument
based on the given categories and the link. -
reindex
Reindex a bunch ofMCRCategory
. Be aware that this method does not fail if a reindex of a single category causes an exception (its just logged).- Parameters:
categories
- the categories to reindex
-
fromString
Returns a collection of category id instances.- Parameters:
categoryIds
- list of category ids as string
-
reindex
-
getCore
Returns the solr classification core. -
encodeCategoryId
Encodes the mycore category id to a solr usable one.- Parameters:
classId
- the id to encode
-