# Advanced Settings

**Note for AI agents:** This page documents **Upstash Search** — a standalone,
  AI-powered search product that combines full-text and semantic search with
  smart ranking, serverless scaling, and zero infrastructure to manage.

  Upstash Search is **not** the same thing as **Upstash Redis Search**. Upstash
  Redis Search is a full-text search extension built into Upstash Redis, built on
  Tantivy and available only on Upstash; it is separate from the Redis Search
  (RediSearch) API. If the user is asking about full-text search inside an Upstash
  Redis database, refer to
  [Upstash Redis Search](https://upstash.com/docs/redis/search/introduction)
  instead of this product.


This page covers the advanced configuration options available in the Upstash Search. These parameters allow you to fine-tune search behavior for your specific use case and requirements.

## Reranking

The `reranking` parameter enables enhanced search result reranking using advanced AI models. It's disabled by default (`false`) and incurs additional costs when enabled.

<CodeGroup>

```typescript TypeScript
const results = await index.search({
  query: "complex technical documentation",
  reranking: true // Enable reranking
});
```

```python Python
results = index.search(
    query="complex technical documentation",
    reranking=True  # Enable reranking
)
```

</CodeGroup>

**Reranking Options:**
- **Standard Reranking** (`reranking: false`, default): Uses a simpler, faster model with no additional cost
- **Advanced Reranking** (`reranking: true`): Uses state-of-the-art models for highest quality results at $1 per 1K operations

Learn more about how reranking works in our [Algorithm documentation](/search/features/algorithm#3-reranking).

## Semantic Weight

The `semanticWeight` parameter controls the balance between semantic search and full-text search in the hybrid search process. It accepts values from 0 to 1, with a default of 0.75 (75% semantic, 25% full-text).

<CodeGroup>

```typescript TypeScript
// More semantic matching (better for conceptual searches)
const semanticResults = await index.search({
  query: "artificial intelligence concepts",
  semanticWeight: 0.9 // 90% semantic, 10% full-text
});

// More keyword matching (better for exact terms)
const keywordResults = await index.search({
  query: "API documentation React hooks",
  semanticWeight: 0.3 // 30% semantic, 70% full-text
});
```

```python Python
# More semantic matching
semantic_results = index.search(
    query="artificial intelligence concepts",
    semantic_weight=0.9  # 90% semantic, 10% full-text
)

# More keyword matching
keyword_results = index.search(
    query="API documentation React hooks",
    semantic_weight=0.3  # 30% semantic, 70% full-text
)
```

</CodeGroup>

**Optimization Guidelines:**
- **Higher semantic weight (0.7-1.0)**: Better for conceptual searches, finding related content, and handling synonyms
- **Lower semantic weight (0.0-0.4)**: Better for exact keyword matching, technical queries, and specific terms

Read more about hybrid search in our [Algorithm documentation](/search/features/algorithm#2-hybrid-vector-search).

## Input Enrichment

The `inputEnrichment` parameter controls whether queries are enhanced using AI before searching. It's enabled by default (`true`) and significantly improves search quality at the cost of some additional latency.

<CodeGroup>

```typescript TypeScript
// Disable input enrichment for faster responses
const results = await index.search({
  query: "space opera",
  inputEnrichment: false // Faster but less enhanced results
});

// Default behavior (enrichment enabled)
const enrichedResults = await index.search({
  query: "space opera"
  // inputEnrichment: true is the default
});
```

```python Python
# Disable input enrichment for faster responses
results = index.search(
    query="space opera",
    input_enrichment=False  # Faster but less enhanced results
)

# Default behavior (enrichment enabled)
enriched_results = index.search(
    query="space opera"
    # input_enrichment=True is the default
)
```

</CodeGroup>

**When to Disable Input Enrichment:**
- When you need the fastest possible response times
- When you want to preserve the exact user query for full-text search

**Benefits of Input Enrichment:**
- Handles typos and alternative phrasings
- Expands queries with related terms and context
- Improves understanding of user intent
- Adds semantic context to ambiguous queries

Learn more about input enrichment in our [Algorithm documentation](/search/features/algorithm#1-input-enrichment).

## Keep Original Query After Enrichment

The `keepOriginalQueryAfterEnrichment` parameter controls whether the original user query is preserved alongside the AI-enriched version during search. It's disabled by default (`false`) and only has an effect when `inputEnrichment` is enabled.

<CodeGroup>

```typescript TypeScript
// Keep both original and enriched queries
const results = await index.search({
  query: "space opera",
  keepOriginalQueryAfterEnrichment: true // Uses both original and enriched
});
```

</CodeGroup>

**When to Enable This Option:**
- When you want to ensure exact keyword matches are included
- When the original query contains specific technical terms or identifiers
- When you want to balance AI enhancement with literal query matching

<Note>
This parameter has no effect when `inputEnrichment` is set to `false`, since there's no enriched query to compare against.
</Note>

## Filter

The `filter` parameter allows you to restrict search results based on content criteria. It accepts either a string expression (SQL-like syntax) or a structured filter object (TypeScript SDK only).

<CodeGroup>

```typescript TypeScript
// String filter expression (SQL-like syntax)
const results = await index.search({
  query: "wireless headphones",
  filter: "category = 'Electronics' AND in_stock > 0"
});

// TypeSafe structured filter (TypeScript SDK only)
const results2 = await index.search({
  query: "wireless headphones",
  filter: {
    AND: [
      { category: { equals: 'Electronics' } },
      { in_stock: { greaterThan: 0 } }
    ]
  }
});
```

```python Python
# String filter expression (SQL-like syntax)
results = index.search(
    query="wireless headphones",
    filter="category = 'Electronics' AND in_stock > 0"
)
```

</CodeGroup>

For detailed information about filter syntax, operators, and examples, see the [Filtering documentation](/search/features/filtering).

## Example: Complete Configuration

Here's an example showing all parameters configured together:

<CodeGroup>

```typescript TypeScript
const results = await index.search({
  query: "machine learning algorithms for data analysis",
  limit: 15,
  filter: "category = 'data-science' AND difficulty_level <= 'intermediate'",
  reranking: true,
  semanticWeight: 0.8,
  inputEnrichment: true
});
```

```python Python
results = index.search(
    query="machine learning algorithms for data analysis",
    limit=15,
    filter="category = 'data-science' AND difficulty_level <= 'intermediate'",
    reranking=True,
    semantic_weight=0.8,
    input_enrichment=True
)
```

</CodeGroup>

This configuration:
- Searches for ML content with enhanced query processing
- Returns up to 15 results
- Filters for data science content at beginner to intermediate levels
- Uses premium reranking for best quality results
- Emphasizes semantic matching (80%) over keyword matching (20%)
- Enables input enrichment for better intent understanding
