2 votes

Examine Facets

Powerful filtering and faceting directly within the Examine fluent API.

This package requires Examine 1.1.0+.

Usage

Examine Facets integrates seamlessly with the Examine API. Read the Examine docs first.

Register the searcher

There are 2 facet engines available out of the box: Bobo Browse and Multi Facets. Both offer a similar choice of features and performance so it is really a matter of preference.

To perform facet queries the chosen facet engine's Searcher must be registered via ExamineManager. This requires only a few lines of configuration code.

if (examineManager.TryGetIndex("CustomIndex", out IIndex index))
{
    if (index is LuceneIndex luceneIndex)
    {
        var searcher = new BoboFacetSearcher(
            "FacetSearcher",
            luceneIndex.GetIndexWriter(),
            luceneIndex.DefaultAnalyzer,
            luceneIndex.FieldValueTypeCollection
        );

        examineManager.AddSearcher(searcher);
    }
}

Querying

Defining and querying facets is baked right into Examine's fluent API.

Begin a facet query by calling .Facet(string field) within a query, or filter results to a facet with a specific value by calling .Facet(string field, string[] values).

Further optional configuration – such as the minimum number of matches required for a facet to appear, or the maximum number of values to return – can also be configured configured through the fluent API.

examineManager.TryGetSearcher("FacetSearcher", out ISearcher searcher);

var query = searcher.CreateQuery();

query.And().Facet("CustomField").MinHits(10).MaxCount(100);

Results

Facet searches behave the same as any other Examine search. To retreive information about facets there are some handy extension methods.

To get a list of all facets: results.GetFacets();

To get a list of values for a specific facet: results.GetFacet(string field);

To get the number of hits for a specific value: results.GetFacet(string field).GetHits(object value);

Documentation

Source code

 Download package
version 1.1.0

NuGet install instructions for Umbraco 8.1.0-8.18.13

Install-Package Examine.Facets

Package owner

Callum Whyte

Callum Whyte

Callum has 290 karma points

Package Compatibility

This package is compatible with the following versions as reported by community members who have downloaded this package:
Untested or doesn't work on Umbraco Cloud
Version 8.18.x (100%)

You must login before you can report on package compatibility.

Previously reported to work on versions: 8.17.x, 8.16.x, 8.15.x, 8.14.x, 8.13.x, 8.12.x, 8.11.x, 8.10.x, 8.9.x, 8.8.x, 8.7.x, 8.6.x, 8.5.x, 8.4.x, 8.3.x, 8.2.x, 8.1.x, 8.0.x

Package Information

  • Package owner: Callum Whyte
  • Created: 23/01/2021
  • Current version 1.1.0
  • .NET version 4.5.2
  • License MIT
  • Downloads on Our: 482
  • Downloads on NuGet: 16.8K
  • Total downloads : 17.3K

External resources