def test_efficient_filtering_used_when_enabled(os_stores: List[OpensearchVectorStore]):
    """Test that efficient filtering is used when the engine and opensearch version supports it."""
    os_store = os_stores[0]

    with mock.patch.object(
        os_store.client, "_default_approximate_search_query"
    ) as patched_default_approximate_search_query:
        filters = MetadataFilters(
            filters=[
                MetadataFilter(
                    key="location",
                    value=["Nevada", "California", "Illinois"],
                    operator=FilterOperator.IN,
                )
            ]
        )
        os_store.client._efficient_filtering_enabled = False
        os_store.client._method["engine"] = "lucene"
        os_store.client._knn_search_query(
            embedding_field="embedding", query_embedding=[1], k=20, filters=filters
        )
        assert not patched_default_approximate_search_query.called

        os_store.client._efficient_filtering_enabled = True
        os_store.client._knn_search_query(
            embedding_field="embedding", query_embedding=[1], k=20, filters=filters
        )
        assert patched_default_approximate_search_query.called
Test that efficient filtering is used when the engine and opensearch version supports it.
llama-index-integrations/vector_stores/llama-index-vector-stores-opensearch/tests/test_opensearch_client.py