private IEnumerable <AnatomyGroup> breakdownGroupSearch(String groupTitleFormat, String groupName, IEnumerable <AnatomyFacet> parentFacets, String breakdownFacet, IEnumerable <String> breakdownValues)
 {
     foreach (var breakdownValue in breakdownValues)
     {
         AnatomyGroup resultGroup = new AnatomyGroup(String.Format(groupTitleFormat, groupName, breakdownValue));
         resultGroup.Facets = parentFacets.AddSingle(new AnatomyFacet(breakdownFacet, breakdownValue));
         resultGroup.addAnatomy(search(null, resultGroup.Facets, int.MaxValue));
         if (resultGroup.Count > 0)
         {
             resultGroup.addCommand(new BreakdownSearchCallbackCommand("Show Individual Anatomy", true, () => displayAnatomyForGroup(resultGroup)));
             yield return(resultGroup);
         }
     }
 }
        /// <summary>
        /// Given a set of facets, build an AnatomyGroup and return it.
        /// </summary>
        /// <param name="name">The name to give the group.</param>
        /// <param name="facets">The facets to build the group with.</param>
        /// <returns>A new AnatomyGroup based on the search results. Will return null if there are no results.</returns>
        public AnatomyGroup buildGroupFromFacets(String name, IEnumerable <AnatomyFacet> facets)
        {
            Query        query   = buildQuery(null, facets);
            TopDocs      results = searcher.Search(query, int.MaxValue);
            AnatomyGroup group   = null;

            if (results.TotalHits > 0)
            {
                group = new AnatomyGroup(name);
                foreach (var scoreDoc in results.ScoreDocs)
                {
                    var doc   = searcher.Doc(scoreDoc.Doc);
                    int index = BitConverter.ToInt32(doc.GetBinaryValue("DataIndex"), 0);
                    group.addAnatomy(anatomyList[index]);
                }
                group.addCommand(new BreakdownSearchCallbackCommand("Show Individual Anatomy", true, () =>
                {
                    anatomyController.displayAnatomy(String.Format("{0} Anatomy", group.AnatomicalName), group.SelectableAnatomy, SuggestedDisplaySortMode.Alphabetical);
                }));
            }
            return(group);
        }