Reranking adjusts the order of search results using additional signals beyond initial relevance scores, such as user feedback and popularity metrics.

Understanding Reranking

Key Concepts

  1. Ranking Signals

    • Initial relevance score
    • User feedback
    • Popularity metrics
    • Custom weights
  2. Weight Configuration

    • Signal importance
    • Score normalization
    • Dynamic adjustment
    • Feedback incorporation

Search Interactions

Interaction Types

  1. Positive Signals

    {
      "feature_id": "prod_123",
      "interaction_type": "click",
      "position": 2,
      "metadata": {
        "duration_ms": 45000,
        "device": "mobile"
      }
    }
    
  2. Negative Signals

    {
      "feature_id": "prod_456",
      "interaction_type": "skip",
      "position": 1,
      "metadata": {
        "interaction_reason": "not_relevant"
      }
    }
    

Recording Interactions

  1. Required Fields

    • feature_id: Unique identifier for the result
    • interaction_type: Type of interaction (click, skip, etc.)
    • position: Position in search results
    • metadata: Additional context (optional)
  2. Session Tracking

    {
      "session_id": "sess_abc123",
      "search_request": {
        "queries": [
          {
            "type": "text",
            "value": "blue dress",
            "vector_index": "text"
          }
        ]
      }
    }
    

Reranking Configuration

Basic Structure

{
  "reranking_options": {
    "weights": {
      "feedback": 0.7,
      "popularity": 0.3
    },
    "enable_reranking": true,
    "interaction_window_days": 30,
    "min_interaction_threshold": 5
  }
}

Advanced Options

  1. Interaction Windows

    {
      "reranking_options": {
        "interaction_weights": {
          "recent": 0.6,
          "historical": 0.4
        },
        "time_decay": {
          "half_life_days": 7
        }
      }
    }
    
  2. Signal Thresholds

    {
      "reranking_options": {
        "min_signals": {
          "clicks": 10,
          "views": 50
        },
        "confidence_threshold": 0.8
      }
    }
    

Implementation Guide

Recording Interactions

  1. Client-Side Integration

    // Track click interaction
    await mixpeek.trackInteraction({
      feature_id: resultId,
      interaction_type: "click",
      position: resultIndex,
      metadata: {
        device: "mobile",
        duration_ms: viewDuration,
      },
    });
    
  2. Batch Processing

    # Process multiple interactions
    interactions = [
      {
        "feature_id": "prod_123",
        "interaction_type": "click",
        "position": 2
      },
      {
        "feature_id": "prod_456",
        "interaction_type": "skip",
        "position": 1
      }
    ]
    
    await mixpeek.bulk_track_interactions(interactions)
    

Enabling Reranking

# Configure search with reranking
search_request = {
  "queries": [{
    "type": "text",
    "value": "summer dress",
    "vector_index": "text"
  }],
  "reranking_options": {
    "weights": {
      "feedback": 0.7,
      "popularity": 0.3
    },
    "enable_reranking": true
  }
}

results = await mixpeek.search(search_request)

Best Practices

Optimization Tips

  1. Weight Tuning

    • Start with balanced weights (0.5/0.5)
    • Adjust based on interaction volume
    • Monitor impact on key metrics
    • A/B test different configurations
  2. Data Quality

    • Filter bot/spam interactions
    • Validate interaction data
    • Handle edge cases
    • Maintain consistent tracking

Error Handling

Common Issues

  1. Invalid Configuration

    {
      "error": "invalid_weights",
      "message": "Weights must sum to 1.0",
      "weights": {
        "feedback": 0.7,
        "popularity": 0.5
      }
    }
    
  2. Resolution Steps

    • Validate weight configurations
    • Check interaction data format
    • Monitor reranking performance
    • Handle missing signals gracefully

For implementation details and examples, see the Interactions API Reference.