ontology/solr-facet-tree/src/main/java/uk/co/flax/biosolr/builders/ChildNodeFacetTreeBuilder.java
/**
	 * Fetch facets for items containing a specific set of values.
	 * @param searcher the searcher for the collection being used.
	 * @param facetValues the incoming values to use as filters.
	 * @param filterField the item field containing the child values, which will be used
	 * to filter against.
	 * @return a map of node value to child values for the items.
	 * @throws IOException
	 */
Fetch facets for items containing a specific set of values.
@param searcher the searcher for the collection being used.
@param facetValues the incoming values to use as filters.
@param filterField the item field containing the child values, which will be used
to filter against.
@return a map of node value to child values for the items.
Fetch facets for items containing a specific set of values . @param searcher the searcher for the collection being used . @param facetValues the incoming values to use as filters . @param filterField the item field containing the child values which will be used to filter against . @return a map of node value to child values for the items .
private Map<String, Set<String>> filterEntriesByField(SolrIndexSearcher searcher, Collection<String> facetValues,
			String filterField) throws IOException {
		Map<String, Set<String>> filteredEntries = new HashMap<>();
		LOGGER.debug("Looking up {} entries in field {}", facetValues.size(), filterField);
		Query filter = buildFilterQuery(filterField, facetValues);
		LOGGER.trace("Filter query: {}", filter);
		DocSet docs = searcher.getDocSet(filter);
		for (DocIterator it = docs.iterator(); it.hasNext(); ) {
			Document doc = searcher.doc(it.nextDoc(), docFields);
			String nodeId = doc.get(getNodeField());
			Set<String> childIds;
			if (filterField.equals(getNodeField())) {
				childIds = Collections.emptySet();
			} else {
				childIds = new HashSet<>(Arrays.asList(doc.getValues(filterField)));
				LOGGER.trace("Got {} children for node {}", childIds.size(), nodeId);
			}
			filteredEntries.put(nodeId, childIds);
			if (isLabelRequired(nodeId)) {
				recordLabel(nodeId, doc.getValues(getLabelField()));
			}
		}
		return filteredEntries;
	}
private Map < String , Set < String > > filterEntriesByField ( SolrIndexSearcher searcher , Collection < String > facetValues , String filterField ) throws IOException { Map < String , Set < String > > filteredEntries = new HashMap < > ( ) ; LOGGER . debug ( "Looking up {} entries in field {}" , facetValues . size ( ) , filterField ) ; Query filter = buildFilterQuery ( filterField , facetValues ) ; LOGGER . trace ( "Filter query: {}" , filter ) ; DocSet docs = searcher . getDocSet ( filter ) ; for ( DocIterator it = docs . iterator ( ) ; it . hasNext ( ) ; ) { Document doc = searcher . doc ( it . nextDoc ( ) , docFields ) ; String nodeId = doc . get ( getNodeField ( ) ) ; Set < String > childIds ; if ( filterField . equals ( getNodeField ( ) ) ) { childIds = Collections . emptySet ( ) ; } else { childIds = new HashSet < > ( Arrays . asList ( doc . getValues ( filterField ) ) ) ; LOGGER . trace ( "Got {} children for node {}" , childIds . size ( ) , nodeId ) ; } filteredEntries . put ( nodeId , childIds ) ; if ( isLabelRequired ( nodeId ) ) { recordLabel ( nodeId , doc . getValues ( getLabelField ( ) ) ) ; } } return filteredEntries ; }
Fetch facets for items containing a specific set of values.
Fetch facets for items containing a specific set of values .
// Get the children for the node, if necessary // Filtering on the node field - child IDs are redundant // Record the label, if required