---
title: Search Facets
pubDate: 2026-10-03T04:27:21.374Z
meta:
  component:
    title: Couchbase Server
    version: "7.2"
antora:
  editUrl: https://github.com/couchbase/docs-server/edit/release/7.2/modules/fts/pages/fts-search-facets.adoc
  xref: xref:7.2@server:fts:fts-search-facets.adoc[]
---

[Consult the llms.txt file for a full list of contents](/llms.txt)
[View original HTML](/server/7.2/fts/fts-search-facets.html)

# Search Facets

Facets are aggregate information collected on a particular result set. For any search, the user can collect additional facet information along with it.

All the facet examples below, are for the query "`water`" on the beer-sample dataset. FTS supports the following types of facets:

## [](#term-facet)Term Facet

A term facet counts how many matching documents have a particular term for a specific field.

> [!NOTE]
> When building a term facet, use the keyword analyzer. Otherwise, multi-term values get tokenized, and the user gets unexpected results.

### [](#example)Example

* Term Facet - computes facet on the type field which has two values: `beer` and `brewery`.  
curl -X POST -H "Content-Type: application/json" \  
http://localhost:8094/api/index/bix/query -d \  
'{  
    "size": 10,  
    "query": {  
        "boost": 1,  
        "query": "water"  
     },  
    "facets": {  
         "type": {  
             "size": 5,  
             "field": "type"  
         }  
    }  
}'  
The result snippet below only shows the facet section for clarity. Run the curl command to see the HTTP response containing the full results.  
```json  
"facets": {  
    "type": {  
        "field": "type",  
        "total": 91,  
        "missing": 0,  
        "other": 0,  
        "terms": [  
            {  
                "term": "beer",  
                "count": 70  
            },  
            {  
                "term": "brewery",  
                "count": 21  
            }  
        ]  
    }  
}  
```

## [](#numeric-range-facet)Numeric Range Facet

A numeric range facet works by the users defining their own buckets (numeric ranges).

The facet then counts how many of the matching documents fall into a particular bucket for a particular field.

### [](#example-2)Example

* Numeric Range Facet - computes facet on the `abv` field with 2 buckets describing `high` (greater than 7) and `low` (less than 7).  
curl -X POST -H "Content-Type: application/json" \  
http://localhost:8094/api/index/bix/query -d \  
'{  
    "size": 10,  
    "query": {  
        "boost": 1,  
        "query": "water"  
    },  
    "facets": {  
        "abv": {  
            "size": 5,  
            "field": "abv",  
            "numeric_ranges": [  
                {  
                    "name": "high",  
                    "min": 7  
                },  
                {  
                    "name": "low",  
                    "max": 7  
                }  
             ]  
        }  
    }  
}'  
Results:  
```json  
facets": {  
    "abv": {  
        "field": "abv",  
        "total": 70,  
        "missing": 21,  
        "other": 0,  
        "numeric_ranges": [  
            {  
                "name": "high",  
                "min": 7,  
                "count": 13  
            },  
            {  
                "name": "low",  
                "max": 7,  
                "count": 57  
            }  
        ]  
    }  
}  
```

## [](#date-range-facet)Date Range Facet

The Date Range facet is same as numeric facet, but on dates instead of numbers.

Full text search and Bleve expect dates to be in the format specified by [RFC-3339](https://www.ietf.org/rfc/rfc3339.txt), which is a specific profile of ISO-8601 that is more restrictive.

## [](#example-3)Example

* Date Range Facet - computes facet on the 'updated' field that has 2 values old and new.  
curl -XPOST -H "Content-Type: application/json" -uAdministrator:asdasd http://<node>:8094/api/index/bix/query -d '{  
"ctl": {"timeout": 0},  
"from": 0,  
"size": 0,  
"query": {  
            "field": "country",  
            "term": "united"  
},  
        "facets": {  
        "types": {  
        "size": 10,  
        "field": "updated",  
        "date_ranges": [  
        {  
        "name": "old",  
        "end": "2010-08-01"  
        },  
        {  
        "name": "new",  
        "start": "2010-08-01"  
        }  
]  
}  
}  
}'  
Results  
```json  
 "facets": {  
             "types": {  
                "field": "updated",  
                "total": 954,  
                "missing": 0,  
                "other": 0,  
             "date_ranges": [  
              {  
                "name": "old",  
                "end": "2010-08-01T00:00:00Z",  
                "count": 934  
              },  
              {  
                "name": "new",  
                "start": "2010-08-01T00:00:00Z",  
                "count": 20  
              }  
               ]  
             }  
           }  
```