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.17.1

Install-Package Examine.Facets

Package owner

Callum Whyte

Callum Whyte

Callum has 270 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 10.0.x (untested)
Version 9.1.x (untested)
Version 9.0.x (untested)
Version 8.18.x (untested)
Version 8.17.x (untested)
Version 8.16.x (100%)
Version 8.15.x (100%)
Version 8.14.x (100%)
Version 8.13.x (100%)
Version 8.12.x (100%)
Version 8.11.x (100%)
Version 8.10.x (100%)
Version 8.9.x (100%)
Version 8.8.x (100%)
Version 8.7.x (100%)
Version 8.6.x (100%)
Version 8.5.x (100%)
Version 8.4.x (100%)
Version 8.3.x (100%)
Version 8.2.x (100%)
Version 8.1.x (100%)
Version 8.0.x (100%)
Version 7.15.x (untested)
Version 7.14.x (untested)
Version 7.13.x (untested)
Version 7.12.x (untested)
Version 7.11.x (untested)
Version 7.10.x (untested)
Version 7.9.x (untested)
Version 7.8.x (untested)
Version 7.7.x (untested)
Version 7.6.x (untested)
Version 7.5.x (untested)
Version 7.4.x (untested)
Version 7.3.x (untested)
Version 7.2.x (untested)
Version 7.1.x (untested)
Version 7.0.x (untested)

You must login before you can report on package compatibility.

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: 113
  • Downloads on NuGet: 5.8K
  • Total downloads : 5.9K

External resources