def test_search_filters_inference_schema(index_name: str):
    """Test the use of search_filters_inference_schema in retrieval."""
    # Define a dummy schema
    schema = DummySchema(field="test")

    # Create documents
    documents = [
        Document(text="Hello world.", doc_id="1", metadata={"source": "test"}),
    ]

    # Create an index with documents
    index = LlamaCloudIndex.from_documents(
        documents=documents,
        name=index_name,
        project_name=project_name,
        api_key=api_key,
        base_url=base_url,
        organization_id=organization_id,
        verbose=True,
    )

    # Use the retriever with the schema
    retriever = index.as_retriever(search_filters_inference_schema=schema)
    nodes = retriever.retrieve(
        'Search for documents where the metadata has source="test"'
    )

    # Verify that nodes are retrieved
    assert len(nodes) > 0
    assert all(n.node.ref_doc_id == "1" for n in nodes)
    assert all(n.node.metadata["source"] == "test" for n in nodes)
Test the use of search_filters_inference_schema in retrieval.
llama-index-integrations/indices/llama-index-indices-managed-llama-cloud/tests/test_indices_managed_llama_cloud.py