goferito / node-bing-api

Node.js module for the Bing Search API (Cognitive Services)
MIT License
56 stars 28 forks source link

Not clear from docs how to specify options #21

Closed paragjoshi closed 8 years ago

paragjoshi commented 8 years ago

Bing api docs mention options like EnableHighlighting and others in the category of WebSearchOptions. It is not clear how to specify that and when I just experimented with specifying EnableHighlighting : true in the json object passed to Bing.web, the result seems to be the same and without the characters around query. Could you give a snippet example? Thank you so much for a very helpful module!

goferito commented 8 years ago

The implementation doesn't consider the EnableHighlighting option, it ignores options it doesn't know about. I'll add it. Is there something else you are missing?

paragjoshi commented 8 years ago

Thanks for offering to add the option. Yes, another thing is that, in the callback function, there doesn't seem an easy way to access "total results" or the next skip position for the next page. There is a property in json body.d.next but that is whole url. So, I assume that if you are near the end (last page or too few results), the next maybe null. But, that is not straightforward like checking total results. I checked this page where it talks about "Total" but the output JSON from your API seems different. http://www.bing.com/developers/s/apibasics.html

Could you help with that?

paragjoshi commented 8 years ago

Dear goferito, Could you please add these two things? Let me know if I can be of help. Thanks

goferito commented 8 years ago

OOps! Sorry, I totally forgot about this. I'll try to have it today or tomorrow

goferito commented 8 years ago

Hi, sorry for the delay, I added the highlight thing, but the Total number of results seems to be a headache feature for the Bing guys. As far as I can read on their forums, the feature has been added and removed several times over the different versions of the API.

That link that you provide belong to the version 2 of the API. The current version is called Azure version, there that those docs don't match the response you get with this module.

If you find a way to get that number with the Azure version I'll be willing to know and to add it to the implementation, but I get the feeling that it is sadly not supported anymore.

paragjoshi commented 8 years ago

Thank you very much Goferito! Your highlighting works!