Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use the debug parameter in the search method of the SearchClient class in the module azure.search.documents.aio._search_client_async.py #38960

Open
yk7180 opened this issue Dec 20, 2024 · 1 comment
Assignees
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Search

Comments

@yk7180
Copy link

yk7180 commented Dec 20, 2024

  • Package Name: azure-search-documents
  • Package Version: 11.6.08b
  • Operating System: ubuntu
  • Python Version: 3.12

Question

In the official documentation [[1]] regarding the debug parameter for performing index searches using the search method of the SearchClient class in the azure.search.documents.aio._search_client_async.py module of the azure-search-documents library (version 11.6.0b8), it is stated as follows:

Enables a debugging tool that can be used to further explore your Semantic search results. Known values are: "disabled", "speller", "semantic", and "all".

How can I obtain debug information from this debugging tool as an object?

What I Tried

I inferred that setting the debug parameter to a value other than "disabled" would result in the debug information being included in the return value of the search method.

Therefore, I set debug="all" as shown in the [code] and executed the search method, then checked the keys of the returned object of the type AsyncSearchItemPaged. The keys contained in the object are as follows ([output]), and there was no change before and after adding the debug parameter. The key related to the debug information (ex: @search.documentDebugInfo) was not present.

[code]

async def azure_ai_search(search_text: str, top: int, openai_client:OpenAiClient, ai_search_client: AiSearchClient) -> list[Document]:

    vector_query = VectorizedQuery(vector=await generate_embeddings(search_text,openai_client), k_nearest_neighbors=top, fields=ai_search_client.vector_field_name,weight=0.33)

    results = await ai_search_client.search_client.search(
        search_text=search_text,
        query_type=QueryType.SEMANTIC,
        semantic_configuration_name=ai_search_client.semantic_configuration_name if ai_search_client.semantic_configuration_name is not None else "mySemanticSearchConfig",
        vector_queries=[vector_query],
        top=top,
        debug="all"
    )
    keys=[result.keys() async for result in results]
    print(keys[0])

[output]

dict_keys(['url', 'tag', 'content_vector', 'content', 'id', 'metadata', 'document_internal_index', 'last_update', 'source', '@search.score', '@search.reranker_score', '@search.highlights', '@search.captions'])

On the other hand, when checking the JSON data of the API response after executing this, I confirmed the presence of debug information such as "@search.documentDebugInfo".

{"@search.answers":[],"value":[{"@search.score":0.022166667506098747,"@search.rerankerScore":2.606142282485962,"@search.documentDebugInfo":{"semantic":null,"vectors":{"subscores":{"documentBoost":1.0,"text":{"searchScore":8.36231517791748},"vectors":[{"content_vector":{"searchScore":0.6478207111358643,"vectorSimilarity":0.45636302944585094}}]}}},

Why is the debug information that exists in the API response not available as the return value of the search method?

[[1]]: https://learn.microsoft.com/en-us/python/api/azure-search-documents/azure.search.documents.searchclient?view=azure-python-preview

@github-actions github-actions bot added Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Search labels Dec 20, 2024
Copy link

Thank you for your feedback. Tagging and routing to the team member best able to assist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Search
Projects
None yet
Development

No branches or pull requests

2 participants