Package org.opencms.search
Class CmsSearchCategoryCollector
java.lang.Object
org.apache.lucene.search.SimpleCollector
org.opencms.search.CmsSearchCategoryCollector
- All Implemented Interfaces:
org.apache.lucene.search.Collector,org.apache.lucene.search.LeafCollector
Collects category information during a search process.
Please note: The calculation of the category count slows down the search time by an order of magnitude. Make sure that you only use this feature if it's really required! Be especially careful if your search result list can become large (> 1000 documents), since in this case overall system performance will certainly be impacted considerably when calculating the categories.
- Since:
- 6.0.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringCategory used in case the document belongs to no category. -
Constructor Summary
ConstructorsConstructorDescriptionCmsSearchCategoryCollector(org.apache.lucene.search.IndexSearcher searcher) Creates a new category search collector instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidcollect(int id) protected voiddoSetNextReader(org.apache.lucene.index.LeafReaderContext ctx) static final StringformatCategoryMap(Map<String, Integer> categories) Convenience method to format a map of categories in a nice 2 column list, for example for display of debugging output.Returns the category count result, the returned map contains Strings (category names) mapped to an Integer (the count).org.apache.lucene.search.ScoreModetoString()Methods inherited from class org.apache.lucene.search.SimpleCollector
getLeafCollector, setScorerMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.lucene.search.Collector
setWeightMethods inherited from interface org.apache.lucene.search.LeafCollector
collect, competitiveIterator, finish
-
Field Details
-
UNKNOWN_CATEGORY
Category used in case the document belongs to no category.- See Also:
-
-
Constructor Details
-
CmsSearchCategoryCollector
Creates a new category search collector instance.- Parameters:
searcher- the index searcher used
-
-
Method Details
-
formatCategoryMap
Convenience method to format a map of categories in a nice 2 column list, for example for display of debugging output.- Parameters:
categories- the map to format- Returns:
- the formatted category map
-
collect
- Specified by:
collectin interfaceorg.apache.lucene.search.LeafCollector- Specified by:
collectin classorg.apache.lucene.search.SimpleCollector- See Also:
-
getCategoryCountResult
Returns the category count result, the returned map contains Strings (category names) mapped to an Integer (the count).- Returns:
- the category count result
-
scoreMode
- See Also:
-
toString
-
doSetNextReader
- Overrides:
doSetNextReaderin classorg.apache.lucene.search.SimpleCollector- See Also:
-