# Facet spatial

## Feature

Create a facet spatial

## How to

1. Configure facet

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

    var rersult = documentCollection
        .Select()
        .FacetSpatial("AliasName", q => q.StoredAt, new GeoCoordinate(1, 1), 10)
        .Execute();
```

1. Optionally, change one or more settings

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

    var rersult = documentCollection
        .Select()
        .FacetSpatial("AliasName", q => q.StoredAt, new GeoCoordinate(1, 1), 10, facet =>
        {
            facet.Minimum = 3;
            facet.Limit = 5;
        })
        .Execute();
```

1. Read data

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

    foreach (FacetItemField facetItem in data)
    {
        // facetName = "InStock" or some alias (if configured)
        var facetName = facetItem.Name;
        //facetType = FacetType.Field
        var facetType = facetItem.FacetType;

        foreach (FacetItemQuery facetItem in data)
        {
            // facetName = "AliasName"
            var facetName = facetItem.Name;
            //facetType = FacetType.Query
            var facetType = facetItem.FacetType;
            // nested = nested facet (if configured)
            var nested = facetItem.Facets;
            // quantity = quantity of item's value
            var quantity = facetItem.Quantity;
        }
    }
```

## Settings

| Use case                                                                                       | How to                                                                                                                                |
| ---------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
| Sort type of result of facet                                                                   | .FacetSpatial("AliasName", q => q.StoredAt, new GeoCoordinate(1, 1), 10, facet => facet.SortType(FacetSortType.CountAsc))             |
| Minimum count of itens in facet's result                                                       | .FacetSpatial("AliasName", q => q.StoredAt, new GeoCoordinate(1, 1), 10, facet => facet.Minimum(2))                                   |
| Limit of itens in facet's result                                                               | .FacetSpatial("AliasName", q => q.StoredAt, new GeoCoordinate(1, 1), 10, facet => facet.Limit(10))                                    |
| List of tags to exclude in facet calculation                                                   | .FacetSpatial("AliasName", q => q.StoredAt, new GeoCoordinate(1, 1), 10, facet => facet.Excludes(new\[] { "tag1", "tag2" }))          |
| Function used in spatial filter                                                                | .FacetSpatial("AliasName", q => q.StoredAt, new GeoCoordinate(1, 1), 10, facet => facet.FunctionType(SpatialFunctionType.Bbox))       |
| Specify a filter or list of filters to be intersected with the incoming domain before faceting | .FacetSpatial("AliasName", q => q.StoredAt, new GeoCoordinate(1, 1), 10, facet => facet.Filter(f => f.Field(q => q.Id).EqualsTo(10))) |

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

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


---

# Agent Instructions: 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.3.1/tutorials/facets/spatial.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.
