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

# Search (text) dataset

> LayersQL Search (text) dataset reference for analyzing text search queries grouped by canonical term, with metrics for clicks, conversions, and zero results.

* **Label:** Search (Text)
* **Description:** Text search analytics.
* **Default group key:** `term`

<Note>
  When you group search text metrics by term, query variants are automatically
  consolidated into a single canonical form. This includes:

  * **Spelling and plural variations** — searches for "charm", "charms", and "charmed" are grouped together under one entry.
  * **Autocomplete prefixes** — keystroke-by-keystroke terms that users type before reaching their final query (for example, "cro", "cros", and "cross") are rolled up into the longest matching term.

  When both apply, prefixes resolve through the cluster mapping. For instance, if "cross" maps to the canonical term "cross necklace", then "cro" and "cros" are also attributed to "cross necklace".

  After consolidation, results are re-sorted so the highest-volume terms appear first. This gives you a clearer picture of true search demand without noise from partial keystrokes, spelling variations, or plural forms.
</Note>

## Metrics

* **requests (requests)**
  * Number of search requests.
  * Example: COUNT\_DISTINCT(requests)
* **results\_count (results)**
  * Results returned per search request.
  * Example: AVG(results\_count)
* **total\_sales (USD)**
  * Sales attributed to search.
  * Example: SUM(total\_sales)
* **quantity\_purchased (items)**
  * Number of items purchased from search traffic.
  * Example: SUM(quantity\_purchased)
* **view\_sessions (sessions)**
  * Sessions where a product was viewed from search results.
  * Example: COUNT\_DISTINCT(view\_sessions)
* **cart\_sessions (sessions)**
  * Sessions where a product from search results was added to cart.
* **quantity\_added\_to\_cart (items)**
  * Items added to cart from search results.

## Dimensions

* **term:** The search query string.
* **query\_type:** Type of search query.
* **language:** Best-effort ISO language code inferred from the search query (for example, `en`, `fr`, `pt-br`). Empty when the query is too short or ambiguous to detect confidently, and only populated for text queries.
* **num\_results:** Number of results returned.
* **current\_page:** Current page index for paginated results (1-based).
* **shopping\_channel:** The shopping channel (e.g., online\_store).
* **billable:** Whether this request is counted for billing.
* **attribution\_token:** Token used to attribute downstream events/purchases.
* **experiment\_id:** Experiment identifier.
* **experiment\_group:** Experiment group/variant.
* **device:** Device category.
* **os:** Operating system.
* **geo\_country:** Two-letter country code.
* **geo\_state:** Up to three-letter province code.
* **geo\_city:** City name as captured.
* **marketing\_source:** UTM source.
* **marketing\_medium:** UTM medium.
* **marketing\_campaign:** UTM campaign.

## Examples

Search requests by term (last 7 days)

```sql theme={null}
FROM search_text
SHOW COUNT_DISTINCT(requests)
GROUP BY term
SINCE -7d
```

Search revenue by country (this month)

```sql theme={null}
FROM search_text
SHOW SUM(total_sales)
GROUP BY geo_country
SINCE this_month
```

Top search terms with zero results

```sql theme={null}
FROM search_text
SHOW COUNT_DISTINCT(requests)
GROUP BY term
WHERE num_results = 0
SINCE -7d
```

Search volume by detected language (last 30 days)

```sql theme={null}
FROM search_text
SHOW COUNT_DISTINCT(requests)
GROUP BY language
SINCE -30d
```

Top French-language search terms (last 30 days)

```sql theme={null}
FROM search_text
SHOW COUNT_DISTINCT(requests)
GROUP BY term
WHERE language = 'fr'
SINCE -30d
```

## Next steps

* [LayersQL syntax](/platform/layersql/syntax)
* [LayersQL functions](/platform/layersql/functions)
* [Datasets overview](/platform/layersql/datasets)
