> For the complete documentation index, see [llms.txt](https://solr-express.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://solr-express.gitbook.io/docs/5.4.0/tutorials/facets/range.md).

# Facet range

## Feature

Create a facet range

## How to

1. Configure facet

```csharp
    DocumentCollection<TechProductDocument> documentCollection; // from DI

    var rersult = documentCollection
        .Select()
        // gap: "1", start: "10", end: "100"
        .FacetRange("AliasName", q => q.Price, "1", "10", "100")
        .Execute();
```

1. Optionally, change one or more settings

```csharp
    DocumentCollection<TechProductDocument> documentCollection; // from DI

    var rersult = documentCollection
        .Select()
        .FacetRange("AliasName", q => q.Price, "1", "10", "100", facet =>
        {
            facet.Minimum = 3;
            facet.Limit = 5;
        })
        .Execute();
```

1. Read data

```csharp
    rersult
        .Facets(out var data);

    foreach (FacetItemRange facetItem in data)
    {
        // facetName = "AliasName"
        var facetName = facetItem.Name;
        //facetType = FacetType.Range
        var facetType = facetItem.FacetType;

        foreach (FacetItemRangeValue<decimal> facetItemValue in facetItem.Values)
        {
            // nested = nested facet (if configured)
            var nested = facetItemValue.Facets;
            // minimumValue = minimum value of item
            var minimumValue = facetItemValue.MinimumValue;
            // maximumValue = maximum value of item
            var maximumValue = facetItemValue.MaximumValue;
            // quantity = quantity of item's value
            var quantity = facetItemValue.Quantity;
        }
    }
```

## 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))                                |

&#x20;**NOTE**&#x20;

Learn more about [queries](http://solr-express.readthedocs.io/en/stable/tutorials/basic-features/queries)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://solr-express.gitbook.io/docs/5.4.0/tutorials/facets/range.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
