Bing search API - How to localize results?

為{幸葍}努か 提交于 2019-12-13 14:38:18

问题


How can I use Slovenian search results by default? Our server has German IP and Bing API automatically shows German results first. I have already tried some of the parameters as described in documentation and none of them worked so far.

Thanks


回答1:


Have you tried to set the Market option?

According to this example page, you should try something like this (note &Market=sl-SL argument):

http://api.bing.net/json.aspx?AppId=your_AppId&Query=your_query&Sources=Web&Version=2.0&Market=sl-SL&Options=EnableHighlighting&Web.Count=10&Web.Offset=0&JsonType=callback&JsonCallback=SearchCompleted



回答2:


Values for the Market parameter




回答3:


First off, Slovenia is currently not a Bing Market or Country.

There are 2 mutually exclusive options to configure a localization. Since Slovenia is not yet supported, you might want to use 2. to combine results from relevant markets.

  • Using mkt and setLang

The values for mkt - Market Code are here.

The query value setLang, "The language to use for user interface strings. Specify the language using the ISO 639-1 2-letter language code. For example, the language code for English is EN. The default is EN (English)."

https://api.cognitive.microsoft.com/bing/v7.0/search?q=microsoft&mkt=en-US&setLang=EN
  • Using cc and Accept-Language

The values for cc - Country Code are here.

This allows you to specify multiple languages via the header value Accept-Language.

https://api.cognitive.microsoft.com/bing/v7.0/search?q=microsoft&cc=US

True, setting the Accept-Language does very little for the actual result. If you want to localize outside of a Bing market country, you'll like have to include a translation service.



来源:https://stackoverflow.com/questions/5677824/bing-search-api-how-to-localize-results

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