What are the query length limits for the Bing WebSearch API?

让人想犯罪 __ 提交于 2019-11-28 04:42:06

问题


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.


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/15334531/what-are-the-query-length-limits-for-the-bing-websearch-api

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!