- Newest
- Most votes
- Most comments
When working with OpenSearch Serverless, particularly with vector search collections, the approach for updating documents differs from traditional Elasticsearch or OpenSearch practices. Here's what you need to know:
-
For vector search collections in OpenSearch Serverless, you cannot index by custom document ID or use upsert requests. This is a limitation specific to this type of collection.
-
The best practice for updating documents in this scenario depends on your specific use case, but here are some approaches to consider:
a. Use the OpenSearch-provided ID: When you index a document, OpenSearch Serverless will generate an ID. You should store this ID along with your application-specific identifiers (like tenant+system+sourceId+type) in a separate database, such as Amazon DynamoDB. This allows you to maintain a mapping between your logical identifiers and the OpenSearch document IDs.
b. Update by document ID: Once you have the OpenSearch-generated ID (retrieved from your mapping database), you can use it to update the document directly. This is more efficient than searching for the document first.
c. Avoid frequent updates if possible: Vector search collections are optimized for search operations rather than frequent updates. If your use case involves frequent updates, you might want to consider using a different collection type or restructuring your data model.
-
Searching for a document and then updating based on the search result is generally not recommended as the primary update strategy, especially for frequent updates. As you correctly pointed out, this would lead to increased search traffic and potential performance issues.
-
Consider your update frequency and volume:
- For infrequent updates, the lookup table approach (storing OpenSearch IDs in DynamoDB) can work well.
- For high-volume updates, you might want to batch your updates or reconsider your data model to minimize the need for updates in the vector search collection.
Remember, OpenSearch Serverless applies eventual consistency for updates. When you update a document, the old version is marked as deleted, and a new document is added. The old version doesn't disappear immediately but becomes inaccessible. OpenSearch cleans up deleted documents in the background as you continue to index more data.
In summary, the recommended approach is to maintain a mapping of your logical identifiers to OpenSearch-generated IDs, use these IDs for updates, and design your data model and update strategy to align with the strengths of vector search collections in OpenSearch Serverless.
Sources
What is Amazon OpenSearch Serverless? - Amazon OpenSearch Service
Community | Unleashing CRUD Prowess: OpenSearch and Golang, a Dynamic Duo
answered 2 years ago
Relevant content
asked 3 years ago
- AWS OFFICIALUpdated 3 years ago
