Develop a Python script that connects to an OpenSearch instance, creates an index called "products", and inserts 10 sample product documents with fields: id, name, description, price, and category.
PLAINFORMAT
from elasticsearch import Elasticsearch

# Replace these variables with your OpenSearch instance information
opensearch_host = "your_opensearch_host"
opensearch_port = 9200
opensearch_user = "your_opensearch_user"
opensearch_password = "your_opensearch_password"

# Connect to the OpenSearch instance
es = Elasticsearch(
    hosts=[{"host": opensearch_host, "port": opensearch_port}],
    http_auth=(opensearch_user, opensearch_password),
)

# Create the 'products' index
index_name = "products"
if not es.indices.exists(index=index_name):
    es.indices.create(index=index_name)

# Insert sample product documents
sample_products = [
    {"id": 1, "name": "Product 1", "description": "Description 1", "price": 10.0, "category": "Category A"},
    {"id": 2, "name": "Product 2", "description": "Description 2", "price": 20.0, "category": "Category B"},
    # Add more sample products here...
]

for product in sample_products:
    es.index(index=index_name, id=product["id"], body=product)

print("Sample products have been inserted into the 'products' index.")