3
$\begingroup$

I run the following commands in Mathematica.

service=ServiceConnect["BingSearch"]

It opens up a dialog box with link to BingSearch. The link takes me to my azure portal (https://portal.azure.com/#home).

I click All services then select Marketplace and in its search bar I search for "Bing" and get the list containing the following:

  • Bing Maps API for Enterprise
  • Bing Custom Search
  • Bing Spell Check v7
  • Bing Search v7
  • Bing Entity Search
  • Bing Autosuggest v7
  • ...

I choose Bing Search v7 and click create and follow the wizard to deploy the API.

I click my deployed API and it says Congratulations! Your keys are ready..

I have Azure subscription with Subscription ID in the following format:

"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"

If I go to manage keys section of my API, I see the following information:

  • NAME: "BingSearchAPI" <-- This is the name I gave when deploying the API
  • KEY 1: "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
  • KEY 2: "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

Now going back to the ServiceConnect dialog box, it asks for my Subscription Key what should i put here? My Azure Subscription ID or API KEY 1 or API KEY 2.

Next on sending a query like:

ServiceExecute[
    service,
    "Search",{
        "Query"->"NASA",
        "Site"->"www.google.com/*",
        MaxItems->2,
        "SearchType"->"Web"
    }
]

I get another dialog box which says:

You are attempting to read from the domain:

...vadq.cloudapp.net

The server is requesting authentication.

(These values are kept for this session only.)

Username: [...]

Password: [...]

What username or password it is requesting here?

Also did I choose the wrong API. Should I have chosen Bing Custom Search instead?

$\endgroup$
0
$\begingroup$

Ok now I can confirm that the API is indeed Bing Search v7 and not Bing Custom Search. I went into the directory "..\SystemFiles\Components\BingSearch\Kernel" and looked at the file "BingSearch.m" and found the following function

bingsearchdata["RawSearch"] :=
    {
    "URL"                -> (ToString@StringForm["https://api.cognitive.microsoft.com/bing/v5.0/`1`", #]&),
    "HTTPSMethod"        -> "GET",
    "Parameters"        -> {"count", "offset", "q", "responseFilter", "safeSearch"},
    "PathParameters"    -> {"SearchTypePath"},
    "RequiredParameters"-> {"SearchTypePath"},
    "ResultsFunction"    -> BSFormatResults
    }

We can see that the end-point URL it is using is "https://api.cognitive.microsoft.com/bing/v5.0/`1`".

On the azure portal I can see that the endpoint for

  • Bing Search is https://api.cognitive.microsoft.com/bing/v7.0
  • Bing Custom Search is https://api.cognitive.microsoft.com/bingcustomsearch/v7.0

So it is indeed using Bing Search as opposed to Bing Custom Search but the version number is incorrect 7.0 vs 5.0. I have fixed that in the code. And now the "BingSearch" in ServiceConnect works!

See: https://docs.microsoft.com/en-us/azure/cognitive-services/bing-web-search/bing-web-upgrade-guide-v5-to-v7

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.