List of usage examples for org.apache.solr.search DelegatingCollector DelegatingCollector
DelegatingCollector
From source file:org.typo3.solr.search.AccessFilter.java
License:Apache License
/** * A modified delegating collector that runs after queries and filters * but before sorting and grouping collectors, see the SOLR PostFilter interface. * * @param searcher/*from ww w . ja va2 s . c o m*/ * @return A delegating collector that can be called by SOLR for PostFilter processing. */ @Override public DelegatingCollector getFilterCollector(IndexSearcher searcher) { return new DelegatingCollector() { SortedDocValues acls; SortedSetDocValues aclsSet; boolean isMultivalue; /** * This method is run whenever we reach the a new index segment, when * this happens we need to load a new set of DocValues. * * @param context * @throws IOException */ public void doSetNextReader(LeafReaderContext context) throws IOException { DocValuesType type = context.reader().getFieldInfos().fieldInfo(accessField).getDocValuesType(); isMultivalue = type.equals(DocValuesType.SORTED_SET); if (isMultivalue) { aclsSet = context.reader().getSortedSetDocValues(accessField); } else { acls = context.reader().getSortedDocValues(accessField); } super.doSetNextReader(context); } /** * Called for each document that need to be considered, if we do * not call super.collect, the document will effectively be filtered here. * * * @param doc * @throws IOException */ @Override public void collect(int doc) throws IOException { if (isMultivalue && handleMultivalueAccessField(doc, aclsSet)) { super.collect(doc); } if (!isMultivalue && handleSingleValueAccessField(doc, acls)) { super.collect(doc); } } }; }