> ## Documentation Index
> Fetch the complete documentation index at: https://docs.heychocolate.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Search

> Search across products, suppliers, and sustainability data by sector, score, and attributes.

The Search module provides powerful full-text and faceted search across all sustainability data in the platform.

## Basic search

```graphql theme={null}
query {
  search(query: "bio-based window frame") {
    totalCount
    results {
      ... on Product {
        id
        name
        sectorTag
        impactScore { co2Equivalent mkiScore }
      }
      ... on Supplier {
        id
        name
        country
      }
    }
  }
}
```

## Filtered search

Narrow results using sector, score ranges, certifications, and more:

```graphql theme={null}
query {
  searchProducts(input: {
    query: "window frame"
    filters: {
      sectorTag: HIGHTECH_MANUFACTURING
      co2Range: { min: 0, max: 20 }
      mkiRange: { min: 0, max: 1.5 }
      certifications: ["ISO14001"]
      countries: ["NL", "DE", "BE"]
    }
    sort: { field: CO2_EQUIVALENT, direction: ASC }
    first: 20
  }) {
    totalCount
    edges {
      node {
        id
        name
        sectorTag
        impactScore { co2Equivalent mkiScore }
        certifications
      }
    }
    pageInfo {
      hasNextPage
      endCursor
    }
    facets {
      sectorTag { value count }
      certifications { value count }
      countries { value count }
    }
  }
}
```

## Available filters

| Filter               | Type      | Description                                                          |
| -------------------- | --------- | -------------------------------------------------------------------- |
| `sectorTag`          | Enum      | `AGRI`, `FOOD`, `HIGHTECH_MANUFACTURING`, `GREEN_CHEMISTRY`, `TRADE` |
| `co2Range`           | Range     | Min/max CO2 equivalent in kg                                         |
| `mkiRange`           | Range     | Min/max MKI score in EUR                                             |
| `certifications`     | \[String] | Filter by certification IDs                                          |
| `countries`          | \[String] | ISO country codes                                                    |
| `materialType`       | String    | Material composition filter                                          |
| `recycledContentMin` | Float     | Minimum recycled content percentage                                  |
| `hasEpd`             | Boolean   | Products with EPD data                                               |
| `hasDpp`             | Boolean   | Products with a Digital Product Passport                             |

## Sort options

| Field            | Description                |
| ---------------- | -------------------------- |
| `CO2_EQUIVALENT` | Sort by carbon footprint   |
| `MKI_SCORE`      | Sort by MKI score          |
| `NAME`           | Alphabetical by name       |
| `CREATED_AT`     | Newest first               |
| `RELEVANCE`      | Search relevance (default) |

## Faceted results

Search responses include facets for building filter UIs:

```json theme={null}
{
  "facets": {
    "sectorTag": [
      { "value": "HIGHTECH_MANUFACTURING", "count": 42 },
      { "value": "TRADE", "count": 18 }
    ],
    "certifications": [
      { "value": "ISO14001", "count": 35 },
      { "value": "BREEAM", "count": 12 }
    ]
  }
}
```

## Autocomplete

For search-as-you-type experiences:

```graphql theme={null}
query {
  autocomplete(query: "bio-bas", limit: 5) {
    suggestions {
      text
      type
      id
    }
  }
}
```
