async def test_clear(
    es_store: ElasticsearchStore,
    node_embeddings: List[TextNode],
    use_async: bool,
) -> None:
    """Test that clear/aclear methods properly delete all data from the index."""
    if use_async:
        await es_store.async_add(node_embeddings)
    else:
        es_store.add(node_embeddings)

    q = VectorStoreQuery(query_embedding=[1.0, 0.0, 0.0], similarity_top_k=10)
    if use_async:
        res = await es_store.aquery(q)
    else:
        res = es_store.query(q)
    assert len(res.nodes) > 0

    if use_async:
        await es_store.aclear()
    else:
        es_store.clear()

    if use_async:
        await es_store.async_add([node_embeddings[0]])
        res = await es_store.aquery(q)
    else:
        es_store.add([node_embeddings[0]])
        res = es_store.query(q)

    assert len(res.nodes) == 1
    assert res.nodes[0].node_id == node_embeddings[0].node_id
Test that clear/aclear methods properly delete all data from the index.
llama-index-integrations/vector_stores/llama-index-vector-stores-elasticsearch/tests/test_vector_stores_elasticsearch.py