- Newest
- Most votes
- Most comments
Editing Cluster Configuration: You can modify certain configurations of an Amazon OpenSearch Service cluster after creation:
- Change instance type: Scale up or down based on performance needs.
- Modify EBS volume size: Increase the size of EBS volumes.
Estimation for 500,000 documents (50 KB each):
- Total data size: 25 GB
- EBS volume: Start with 50 GiB, scale up if needed.
- Instance type: Start with
r5.large.search, scale tor5.xlarge.searchfor better performance.
Index Settings: Once created, you cannot change:
number_of_shardsnumber_of_replicasindex.knn
Create a new index and reindex data if changes are needed.
KNN Parameters:
ef_construction: Start with 128 for a balance between build time and query performance.m: Use a value between 16 and 32.space_type: Usel2for Euclidean distance.
Sample Index Creation:
PUT /awesome_index { "settings": { "index.knn": true, "number_of_shards": 2, "number_of_replicas": 1 }, "mappings": { "properties": { "vector_field": { "type": "knn_vector", "dimension": 1024, "method": { "name": "hnsw", "space_type": "l2", "parameters": { "ef_construction": 128, "m": 24 } } } } } }
Creating and editing an Amazon OpenSearch instance via the console is a straightforward process. Here's how you can do it and address your questions:
-
Creating the OpenSearch domain: You can create an OpenSearch domain through the AWS console by navigating to the Amazon OpenSearch Service section and clicking "Create domain". You've mentioned using 'r5.large.search' instance type with 50GiB EBS volume (gp2).
-
Editing values later: Yes, you can edit these values later. Amazon OpenSearch Service allows you to modify your domain configuration after creation. You can change instance types, increase storage, and adjust other settings as your needs evolve.
-
Estimating resources for 500,000 documents: For 500,000 documents of approximately 50KB each, you're looking at about 25GB of raw data. As a general rule, you should allocate 2-3 times this amount for OpenSearch, so your initial 50GB should be sufficient to start. However, for better performance as your data grows, you might want to consider scaling up to a larger instance type (like r5.xlarge.search) and increasing your EBS volume size.
-
Index settings: Regarding your index creation, you're correct that some settings cannot be changed after the index is created. This includes the number of primary shards. However, you can change the number of replicas later.
-
KNN-specific settings: For KNN search, setting "index.knn" to true is correct. The other parameters like "ef_construction" and "space_type" depend on your specific use case:
- "space_type": "l2" is commonly used for Euclidean distance, which is often suitable for text embeddings.
- "ef_construction": 128 is a reasonable starting point. Higher values can improve search quality but increase indexing time.
- "m": 24 is also a reasonable default. It affects the number of connections per node in the graph.
These values often require tuning based on your specific data and performance requirements. Start with these defaults and adjust based on your observed performance.
Remember, while you can't change these settings for an existing index, you can create a new index with adjusted settings and reindex your data if needed.
Lastly, when working with text embeddings, ensure your "dimension" parameter matches the size of your embedding vectors. In your example, it's set to 1024, which should align with your embedding model's output.
As you scale and optimize your OpenSearch deployment, keep monitoring your cluster's performance and adjust these settings accordingly.
Sources
Community | Search and Analyze data in Amazon OpenSearch using SQL
Create an Amazon OpenSearch Service domain - Amazon OpenSearch Service
Using the AWS SDKs to interact with Amazon OpenSearch Service - Amazon OpenSearch Service
answered 2 years ago

@Jainam - thank you . one follow up question, if i want to use, cosine similarity instead of eucledian distance, i assume i don't have to specify space_type: "l2", right? what settings would make sense in case of cosine ? I'm doing this as a POC , but there will few users testing this, what number of shards and replicas , at minimum would you recommend?