# CrowdingSpec

- [JSON representation](https://docs.cloud.google.com/gemini/enterprise/docs/reference/rest/v1/CrowdingSpec#SCHEMA_REPRESENTATION)
- [Mode](https://docs.cloud.google.com/gemini/enterprise/docs/reference/rest/v1/CrowdingSpec#Mode)

Specification for crowding. Crowding improves the diversity of search results by limiting the number of results that share the same field value. For example, crowding on the color field with a maxCount of 3 and mode DROP_CROWDED_RESULTS will return at most 3 results with the same color across all pages.

| JSON representation |
|---|
| ``` { "field": string, "maxCount": integer, "mode": enum (`https://docs.cloud.google.com/gemini/enterprise/docs/reference/rest/v1/CrowdingSpec#Mode`) } ``` |

| Fields ||
|---|---|
| `field` | `string` The field to use for crowding. Documents can be crowded by a field in the `https://docs.cloud.google.com/gemini/enterprise/docs/reference/rest/v1/projects.locations.collections.dataStores.branches.documents#Document` object. Crowding field is case sensitive. |
| `maxCount` | `integer` The maximum number of documents to keep per value of the field. Once there are at least maxCount previous results which contain the same value for the given field (according to the order specified in `orderBy`), later results with the same value are "crowded away". If not specified, the default value is 1. |
| `mode` | ``enum (`https://docs.cloud.google.com/gemini/enterprise/docs/reference/rest/v1/CrowdingSpec#Mode`)`` Mode to use for documents that are crowded away. |

## Mode

Enum describing the mode to use for documents that are crowded away. They can be dropped or demoted to the later pages.

| Enums ||
|---|---|
| `MODE_UNSPECIFIED` | Unspecified crowding mode. In this case, server behavior defaults to `https://docs.cloud.google.com/gemini/enterprise/docs/reference/rest/v1/CrowdingSpec#Mode.ENUM_VALUES.DROP_CROWDED_RESULTS`. |
| `DROP_CROWDED_RESULTS` | Drop crowded results. |
| `DEMOTE_CROWDED_RESULTS_TO_END` | Demote crowded results to the later pages. |