# Search

**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.


## Search Command for Python SDK

The search method is designed to retrieve the most relevant documents from the database, using AI-powered search capabilities.

For more details on how the search algorithm works, please refer to our [advanced settings documentation](/search/features/advanced-settings).

### Arguments

<ResponseField name="Payload" type="dict" required>
  <Expandable defaultOpen="true">
    <ResponseField name="query" type="string" required>
      The search query string.
    </ResponseField>
    <ResponseField name="limit" type="int" required>
      The maximum number of results to return. Defaults to 10.
    </ResponseField>
    <ResponseField name="reranking" type="bool">
      Whether to enable AI-powered reranking of results. Disabled by default.
    </ResponseField>
    <ResponseField name="filter" type="string">
      A [filter](/search/features/filtering) for narrowing down the search results based on content fields.
    </ResponseField>
    <ResponseField name="semantic_weight" type="number">
      Optional relevance balance between semantic and keyword search (0-1 range, defaults to 0.75).
      For instance, 0.2 applies 20% semantic matching with 80% full-text matching.
      You can learn more about how Upstash Search works from [our docs](/search/features/algorithm).
    </ResponseField>
    <ResponseField name="input_enrichment" type="boolean">
      Optional boolean to enhance queries before searching (enabled by default).
    </ResponseField>
  </Expandable>
</ResponseField>

### Response

<ResponseField name="Documents" type="List[DocumentScore]" required>
  This field is `null` if no document with the specified ID is found.
  <Expandable defaultOpen="true">
    <ResponseField name="id" type="string | number" required>
      The ID of the resulting document.
    </ResponseField>
    <ResponseField name="content" type="Record<string, unknown>">
      The main content of the document.
    </ResponseField>
    <ResponseField name="metadata" type="Record<string, unknown>">
      Additional metadata for the document.
    </ResponseField>
    <ResponseField name="score" type="float" required>
      Similarity score of the document
    </ResponseField>
  </Expandable>
</ResponseField>

<RequestExample>

```python Basic Search
results = index.search(
    query="space opera",
    limit=2
)
print(results)
```

```python Search with Reranking
results = index.search(
    query="space opera",
    limit=2,
    reranking=True
)
print(results)
```

```python Search with Filter
results = index.search(
    query="space", 
    limit=2, 
    filter="category = 'classic'"
)
print(results)
```
</RequestExample>
