Query Page Generation: From Search Data to SEO-Optimized Pages

This article explains how we automatically generate thousands of query pages from search data.

The Problem: Creating Pages for Every Search Query

Users search for products in many ways:

  • "mini pc for office"

  • "small computer 16gb ram"

  • "compact desktop windows 11"

Each query deserves a dedicated page with:

  • Matching products filtered by query intent

  • SEO-optimized content (title, description, meta tags)

  • Related searches to help users explore

  • Multilingual support for global users

Creating these pages manually is impossible at scale (65,000+ queries).

The Solution: Automated Query Page Generation

The SEO pipeline generates query pages automatically:

  1. Cluster similar queries (e.g., "mini pc" + "small computer")
  2. Extract filters from query text (e.g., "16gb ram" → RAM filter)
  3. Match products using semantic similarity
  4. Generate content with AI (DeepSeek)
  5. Create page at /q/<slug>

Query Page Model

Query pages are stored in DynamoDB using the QueryPageV3 model. Each page has:

  • Slug: URL-friendly identifier (primary key)

  • Filters: Base filters for product matching

  • SKUs: Cached list of top 100 matching SKUs

  • Title: Page title for SEO

  • Descriptions: Multilingual content (tagline + body)

  • Metadata: Last updated timestamp, total score

Generation Process

Query pages are generated by the SEO pipeline:

  1. Cluster queries: Group similar queries using vector similarity
  2. Match products: Find products matching the query cluster
  3. Generate slug: Create URL-friendly identifier
  4. Cache SKUs: Store top 100 matching SKUs
  5. Generate content: AI-generated description

Content Generation

Query page content is generated using AI:

  • DeepSeek: Product descriptions, query page content

  • System prompts: For caching efficiency

  • Temperature: 0.7 for balanced creativity

The AI generates:

  • Tagline: Short, compelling headline

  • Body: Detailed product information

Multilingual Support

Query pages support multiple languages:

  • English (source)

  • Spanish, French, German, Italian, Portuguese

  • Russian, Hindi, Bengali, Gujarati, Kannada

  • Malayalam, Marathi, Punjabi, Tamil, Telugu

  • Arabic, Chinese, Japanese, Korean

Filter Extraction

Filters are extracted from search queries using phrase matching:

  1. Load phrase-to-filter mappings from JSON
  2. Match phrases in query using regex word boundaries
  3. Extract filter key-value pairs
  4. Store as base filters for the query page

Product Matching

Products are matched to query pages using:

  1. Vector similarity: Query embeddings vs product embeddings
  2. Filter matching: Extracted filters vs product attributes
  3. Product name matching: Fuzzy matching on product names

Caching Strategy

Query pages use multiple caching layers:

  • DynamoDB: Primary storage for query page data

  • Valkey: Cached SKUs for fast product loading

  • CloudFront: CDN caching for static content

Request Flow

flowchart TD
    A[Client Request] --> B{Slug exists?}
    B -->|Yes| C[Load QueryPageV3]
    B -->|No| D[Search Products]
    
    C --> E[Parse URL filters]
    E --> F[Merge with base filters]
    F --> G[Get cached SKUs]
    G --> H[Load products]
    H --> I[Render page]
    
    D --> I

Summary

Query page generation provides:

  • Dynamic pages: Auto-generated from search data

  • AI content: Automated content generation

  • Multilingual: Support for 15+ languages

  • Fast loading: Multiple caching layers

  • Smart filtering: Phrase-based filter extraction