# Create a search index
index = hnswlib.Index(space="ip", dim=1536)
index.init_index(
    max_elements=len(doc_embs), ef_construction=512, M=64
)
index.add_items(doc_embs, list(range(len(doc_embs))))
```

## Send Query and Retrieve Documents

Next, we build a function that takes a query as input, embeds it, and finds the three documents that are the most similar to the query.

```python PYTHON