Commands
Upsert
from upstash_search import Search
client = Search(
url="<UPSTASH_SEARCH_REST_URL>",
token="<UPSTASH_SEARCH_REST_TOKEN>",
)
index = client.index("movies")
index.upsert(
documents=[
{
"id": "movie-0",
"content": {
"title": "Star Wars",
"overview": "Sci-fi space opera",
"genre": "sci-fi",
"category": "classic",
},
"metadata": {
"poster": "https://poster.link/starwars.jpg",
},
},
],
)
Upsert Command for Python SDK
Used to add new documents or update an existing document.
Arguments
from upstash_search import Search
client = Search(
url="<UPSTASH_SEARCH_REST_URL>",
token="<UPSTASH_SEARCH_REST_TOKEN>",
)
index = client.index("movies")
index.upsert(
documents=[
{
"id": "movie-0",
"content": {
"title": "Star Wars",
"overview": "Sci-fi space opera",
"genre": "sci-fi",
"category": "classic",
},
"metadata": {
"poster": "https://poster.link/starwars.jpg",
},
},
],
)
Was this page helpful?
from upstash_search import Search
client = Search(
url="<UPSTASH_SEARCH_REST_URL>",
token="<UPSTASH_SEARCH_REST_TOKEN>",
)
index = client.index("movies")
index.upsert(
documents=[
{
"id": "movie-0",
"content": {
"title": "Star Wars",
"overview": "Sci-fi space opera",
"genre": "sci-fi",
"category": "classic",
},
"metadata": {
"poster": "https://poster.link/starwars.jpg",
},
},
],
)
Assistant
Responses are generated using AI and may contain mistakes.