What are the query length limits for the Bing WebS

2019-01-26 17:05发布

Given that the Bing API docs consist primarily of an error-ridden, two-page Word document, I have not been able to find the answer to this online. Trial and error has produced inconsistent results, and given that queries cost money, I'd rather not have to guess and check any more.

What are the length limits are on the new 'Azure marketplace' Bing WebSearch API? I know there is a limit of some sort, because long queries tend to return, "The request was not accepted by the data provider's service. The team is investigating the issue. We are sorry for the inconvenience." However, the query length at which this occurs, both in terms of characters or words, tends to vary based on the query entered. I am using fairly complex queries with advanced operators like site: and instreamset:, so it is very difficult to narrow down what the limitation is. ie: I have successfully made queries of over 1800 characters, and I have had them fail with less than 1200 characters.

标签: bing-api
2条回答
小情绪 Triste *
2楼-- · 2019-01-26 17:36

Updating this answer for the new Cognitive Services (v5.0) version of the Bing Search API:

from https://msdn.microsoft.com/en-us/library/dn760794.aspx#URL%20to%20Send%20Requests%20To:

Note: The maximum URL length is 2,048 characters. To ensure that your URL length does not exceed the limit, the maximum length of your query parameters should be less than 1,500 characters. If the URL exceeds 2,048 characters, the server will return 404 Not found.

查看更多
Lonely孤独者°
3楼-- · 2019-01-26 17:53

Got the answer from Microsoft Support:

It looks like requests that arrive into Data Market have a query string limit of 10240. However; the content provider (in this case Bing Search ) has a limitation of 2048 characters.

Note that the 'query string' in this case is the entire URL, not just the 'Query' argument.

The reason why some URLs shorter than 2048 characters appeared to fail is due to the encoding of spaces. Before passing the query on to Bing, the Azure Data Market re-encodes it, and it uses %20 instead of + to encode spaces. So to check whether your request URL is within the 2048 characters, be sure to hex-encode all special characters, including spaces.

查看更多
登录 后发表回答