Closed v-jaswel closed 4 years ago
Thanks for the feedback. Routing to appropriate team for follow-up
Hi @maggiepint any progress on this issue? Thanks much.
I was looking into this bug again and it appears the problem is in the auto_suggest_search_api.py file. Redoing the very last line, fixes this issue (even though it sounds a different problem than what v-jaswel described). Here is the modification (replace the region with user region or custom domain):
#auto_suggest.metadata = {'url': '/suggestions/'}
auto_suggest.metadata = { 'url': 'https://westus.cognitiveservices.azure.com/bing/v7.0/suggestions/'}
I included the old line to show the diff. This is hardcoded though, so a better fix is needed. But just to illustrate where the bug is.
Using Autosuggest in Python is not useable until this gets fixed. Thanks.
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @jaggerbodas-ms, @arwong.
Closing as fixed. The following updated code snippet runs as expected.
from azure.cognitiveservices.search.autosuggest import AutoSuggestClient
from msrest.authentication import CognitiveServicesCredentials
import json, os, sys
key_var_name = 'AUTOSUGGEST_SUBSCRIPTION_KEY'
if not key_var_name in os.environ:
raise Exception('Please set/export the environment variable: {}'.format(key_var_name))
subscription_key = os.environ[key_var_name]
endpoint_var_name = 'AUTOSUGGEST_ENDPOINT'
if not endpoint_var_name in os.environ:
raise Exception('Please set/export the environment variable: {}'.format(endpoint_var_name))
endpoint = os.environ[endpoint_var_name]
# Instantiate a Bing Autosuggest client
#endpoint = endpoint + "/bing/v7.0"
client = AutoSuggestClient(endpoint, CognitiveServicesCredentials(subscription_key))
result = client.auto_suggest('xb')
print(result.suggestion_groups[0].search_suggestions[0].query)
print(result.suggestion_groups[0].search_suggestions[0].display_text)
Output
xbox
xbox
Describe the bug The path for the autosuggest method is '/Suggestions' when it should be '/bing/v7.0/Suggestions'. As a result, requests to the service return 404 unless the user appends '/bing/v7.0' to their endpoint.
Exception or Stack Trace
The target URL is
https://westus.api.cognitive.microsoft.com/Suggestions?mkt=en-us&q=xb
, as verified by a debug statement inserted at auto_suggest_search_api.py line 309:To Reproduce
Code Snippet
Expected behavior Expected output:
To fix the error, uncomment the following line in the code snippet:
Additional context None