Overriding ResultFacetList


This article describes a breaking change in the .Net Module between earlier versions of and versions and later.

It is only applicable if:

  1. You are trying to upgrade a version prior to to or later, AND
  2. You have overridden the method ResultFacetList

If you haven't overridden the method ResultFacetList, you may safely ignore this article.

Why is this a breaking change?

  1. Prior to, the method ResultFacetList(SearchResult result, params string[] facetKeys) called ResultFacetList(SearchResult result), and ResultFacetList(SearchResult result) implemented the html.
  2. This changed in order to fix a bug.
  3. From version, the order was changed, meaning that ResultFacetList(SearchResult result) now calls ResultFacetList(SearchResult result, params string[] facetKeys), and ResultFacetList(SearchResult result, params string[] facetKeys) implements the actual html.
  4. If your overriding code still depends on the implementation prior to and performs the calls as described in point 1, then when you upgrade to or later, you will most likely get a stack overflow. This is caused by an infinite execution path.

Make sure that you override the ResultFacetList(SearchResult result, params string[] facetKeys) method if you want to change the html, and that it does not call ResultFacetList(SearchResult result).

The new implementations of these methods look as follows:

        /// <summary>
        /// Generates html for the result list showing the facets, higlighting the selected facets
        /// </summary>
        /// <param name="result">the search response</param>
        /// <returns>html string</returns>
        public virtual string ResultFacetList(SearchResult result)
            return ResultFacetList(result, result.Facets.Select(x => x.Key).ToArray());

        /// Generates html for the facets which match the given facetKeys
        ///<param name="result">The search result</param>
        ///<param name="facetKeys">The Facet key</param>
        ///<returns>the html for the facets</returns>
        public virtual string ResultFacetList(SearchResult result, params string[] facetKeys)
            if (result == null || result.Facets == null || !result.Facets.Any() || facetKeys == null || !facetKeys.Any()) return string.Empty;
            if (result.IsNull) return string.Empty;
            List<Facet> filteredFacets = facetKeys.Select(facetKey => result.Facets.FirstOrDefault(f => f.Key.Equals(facetKey))).Where(foundFacet => foundFacet != null).ToList();

            if (!DoRenderResultFacetList(result))
                return string.Empty;
            var aside = this.GetTagByName("aside");
            var h2 = this.GetHeadingByLevel(2);
            aside.InnerHtml += h2.ToString();
            filteredFacets.ForEach(facet => aside.InnerHtml += ResultFacetList_Facet(facet, result.Name));
            return aside.ToString();