solr express
Search…
Facet range

Feature

Create a facet range

How to

    1.
    Configure facet
1
DocumentCollection<TechProductDocument> documentCollection; // from DI
2
3
var rersult = documentCollection
4
.Select()
5
// gap: "1", start: "10", end: "100"
6
.FacetRange("AliasName", q => q.Price, "1", "10", "100")
7
.Execute();
Copied!
    1.
    Optionally, change one or more settings
1
DocumentCollection<TechProductDocument> documentCollection; // from DI
2
3
var rersult = documentCollection
4
.Select()
5
.FacetRange("AliasName", q => q.Price, "1", "10", "100", facet =>
6
{
7
facet.Minimum = 3;
8
facet.Limit = 5;
9
})
10
.Execute();
Copied!
    1.
    Read data
1
rersult
2
.Facets(out var data);
3
4
foreach (FacetItemRange facetItem in data)
5
{
6
// facetName = "AliasName"
7
var facetName = facetItem.Name;
8
//facetType = FacetType.Range
9
var facetType = facetItem.FacetType;
10
11
foreach (FacetItemRangeValue<decimal> facetItemValue in facetItem.Values)
12
{
13
// nested = nested facet (if configured)
14
var nested = facetItemValue.Facets;
15
// minimumValue = minimum value of item
16
var minimumValue = facetItemValue.MinimumValue;
17
// maximumValue = maximum value of item
18
var maximumValue = facetItemValue.MaximumValue;
19
// quantity = quantity of item's value
20
var quantity = facetItemValue.Quantity;
21
}
22
}
Copied!

Settings

Use case
How to
Sort type of result of facet
.FacetRange("AliasName", q => q.Price, "1", "10", "100", facet => facet.SortType(FacetSortType.CountAsc))
Minimum count of itens in facet's result
.FacetRange("AliasName", q => q.Price, "1", "10", "100", facet => facet.Minimum(2))
Limit of itens in facet's result
.FacetRange("AliasName", q => q.Price, "1", "10", "100", facet => facet.Limit(10))
List of tags to exclude in facet calculation
.FacetRange("AliasName", q => q.Price, "1", "10", "100", facet => facet.Excludes(new[] { "tag1", "tag2" }))
Counts should also be computed for all records with field values lower then lower bound of the first range
.FacetRange("AliasName", q => q.Price, "1", "10", "100", facet => facet.CountBefore(true))
Counts should also be computed for all records with field values greater then the upper bound of the last range
.FacetRange("AliasName", q => q.Price, "1", "10", "100", facet => facet.CountAfter(true))
Specify a filter or list of filters to be intersected with the incoming domain before faceting
.FacetRange("AliasName", q => q.Price, "1", "10", "100", facet => facet.Filter(f => f.Field(q => q.Id).EqualsTo(10)))
Specify if last bucket will end at �end� even if it is less than �gap� wide
.FacetRange("AliasName", q => q.Price, "1", "10", "100", facet => facet.HardEnd(true))

NOTE

Learn more about queries
Last modified 2yr ago