Content Search FAQ

On this page




Ready... Scaffold... Search!

Score's Content Search components are designed to work with out-of-the-box Score 2.5 - no special configuration or search provider installation necessary. If you have a working Sitecore instance running on Score 2.5+ then you are ready to begin using the Score's Content Search components.


What If I'm Upgrading From an Older Score?

If your site was scaffolded using an older solution template, and now you've upgraded to Score 2.5+, you will need to add the new components to your placeholder settings and add an index configuration before you can use them. See the Migration Notes page for more details.


What Content Search Components come with Score?




  1. Search Box

  2. Search Query Message
  3. Facet Container
  4. Facet Panel
  5. Active Facets
  6. Search Results (or Live Search Results)
  7. Promo Tile
  8. Suggestion Section



Where Is The Content For The Tiles Coming From?

Score 2.5 introduced a new feature - Page Tiles - which allows pages to create additional content to represent themselves by.


The Search Result and Live Search Results components have a field for "Tile Name". This is where you can specify which tile should be used for search results. By default, Search Results components render a page's "Search Result" tile, and the Suggestion Section component within the Search Box renders the "Autocomplete" tile. If either of these tiles don't exist on the page, Score checks for fallback tiles on the page's Standard Values item. If they don't exist on Standard Values either, Score checks for a tile named "default". This behavior can be configured through boolean flags set through code or through the rendering definition item parameters.



If you are extending Score's Content Search components, here is a list of flags that Score's pipelines currently check for:

  • Count Facets - if true, extra logic will be performed to count how many facets are available for the result set
  • Remove Empty Tiles - if true, tiles with black contents (no components inserted) will be removed from the results set
  • Fallback To Default Tiles - if true, "default" tile will be used when the tile specified by the Tile Name field cannot be found

  


Can I Exclude Content From Search?

Yes, Score Content Search current supports Page-level exclusion and field-level exclusion.

Page-Level Exclusion

Use the "Show in Search Results" field on page items

Content Editor view


Experience Editor View


Field-Level Exclusion

Use the "Exclude From Text Search" field on field items

This can be done from Content Editor only

What Search Provider Does Score Use?

Out of the box, Score's Content Search components use the Lucene indexes that are delivered with every Sitecore installation - sitecore_master_index and sitecore_web_index. But if you have any experience with Score, you know that it's goal is to be flexible and extendable. It wants to break boundaries, not set them. The front-end functionality of the components is completely independent from the back-end search provider implementation. So, you can override the Lucene configuration with any search provider you'd prefer.

If you want to see what the front-end to back-end communication looks like, check out the Search Results API.


How Can I Customize My Search Provider?

Score search is pipeline-driven, and the pipelines are organized by activities:

  • applySearchCriteria - methods that build up the search queryable based on parameters from the request
  • collectResults - methods that manipulate the results set after the queryable has been executed
  • disposeSearchContext - methods that clean up resources


You may override the entire implementation or just specific sections.


Where Do I Specify The Index Name?

Nowhere! Score uses Sitecore's GetContextIndex.FetchIndex processor to determine what index should be used based on the current context item. How does the processor figure this out? - it compare's the item's path with the root paths of crawlers defined for indexes.

Simply patch over this processor if you want to specify your index using a different method.


Can I Add Sections to Score's Content Search Pipelines?

Of course! Here are some code samples to get you going.


Score.Custom.Pipelines.ContentSearch.SearchCriteria.ApplyFacets
namespace Score.Custom.Pipelines.ContentSearch.SearchCriteria
{
    using System.Collections.Generic;
    using System.Linq;
    using Score.Data.ContentSearch;
    using Sitecore.ContentSearch.Pipelines;
    using Sitecore.ContentSearch.SearchTypes;

    /// <summary>
    /// Applies facet filtering to search results of type <see cref="ScoreSearchResult"/>.
    /// </summary>
    public class ApplyFacets : ApplyFacets<ScoreSearchResult> { }

    /// <summary>
    /// Applies facet filtering to search results.
    /// </summary>
    /// <typeparam name="T">The search result item type.</typeparam>
    public class ApplyFacets<T> : SearchPipelineProcessor<SearchCriteriaArgs<T>> where T : SearchResultItem, IFacetableSearchResult
    {
        /// <summary>
        /// Processes the specified arguments.
        /// </summary>
        /// <param name="args">The arguments.</param>
        public override void Process(SearchCriteriaArgs<T> args)
        {
            if (args.FacetFilters == null || !args.FacetFilters.Any())
            {
                return;
            }

            args.IndexQueryable = this.UpdateQueryableWithFacets(args.FacetFilters, args.IndexQueryable);
        }

        /// <summary>
        /// Updates the queryable with facets criteria.
        /// </summary>
        /// <param name="facets">The facets.</param>
        /// <param name="queryable">The queryable.</param>
        /// <returns>IQueryable&lt;SearchResult&gt;.</returns>
        protected IQueryable<T> UpdateQueryableWithFacets(IEnumerable<FacetQuery> facets, IQueryable<T> queryable)
        {
            foreach (var facetQuery in facets)
            {
                if (facetQuery.Values != null && facetQuery.SelectedValues.Any())
                {
                    queryable = facetQuery.UpdateQueryableWithFacets(queryable);
                }
            }

            return queryable;
        }
    }
}
Score.Custom.Pipelines.ContentSearch.SearchResults.RemoveEmptyTiles
namespace Score.Custom.Pipelines.ContentSearch.SearchResults
{
    using Score.Data.ContentSearch;
    using Sitecore.ContentSearch.Pipelines;
    using Sitecore.ContentSearch.SearchTypes;

    public class RemoveEmptyTiles : RemoveEmptyTiles<ScoreSearchResult> { }

    public class RemoveEmptyTiles<T> : SearchPipelineProcessor<SearchResultsArgs<T>> where T : SearchResultItem
    {
        /// <summary>
        /// Processes the specified arguments. Excludes pages with empty tiles from search results.
        /// </summary>
        /// <param name="args">The arguments.</param>
        public override void Process(SearchResultsArgs<T> args)
        {
            if (!args.PipelineSettings.ContainsKey(Setting.RemoveEmptyTiles) || !args.PipelineSettings[Setting.RemoveEmptyTiles])
            {
                return;
            }

            var removed = args.Results.RemoveSearchResultsWhere(x => string.IsNullOrWhiteSpace(x.TileHtml));
            args.Results.TotalNumberOfResults = args.Results.TotalNumberOfResults - removed;
        }
    }
}