6

I am new to Meta so let me know if I need to add clearer information or correct it.

I am currently trying to determine what the differences in functionality between making API calls and using the search bar (in my case on Stack Overflow).

My end goal is to see how complex I can make an API call to narrow down search results, this would be by combining keywords, tags as well as excluding either or both keywords and tags in a single call but I am getting different results so far.

In this current example, I have the keyword oracle and the tag blockchain .

When using the search bar on Stack Overflow, at the time of writing, I get 66 results which you can see here. https://stackoverflow.com/search?q=oracle+%5Bblockchain%5D

Yet if I call the same search (or what I think is the same) using the API and the /excerpts endpoint and append filter=total I am only coming up with 7 results as seen here. https://api.stackexchange.com/2.2/search/excerpts?order=desc&sort=activity&q=oracle&tagged=blockchain&site=stackoverflow&filter=total

Is there something I am missing here that I am missing in this being the same search overall or some comparison documentation that I may have overlooked also?

3
  • 4
    The API seems to be converting the term "oracle" into a tag and searching for the combination of the two tags, resulting in these same 7 results: stackoverflow.com/… I'm not familiar enough with the API to know why it's doing that, though. – animuson Feb 24 at 4:47
  • I had missed that, it does appear to be returning results for oracle and blockchain You mentioned in your comment, your link returns 4 results for me. Do you see 7? When using the API api.stackexchange.com/2.2/search/… I am getting 7 results instead. I think you are correct in that it is being seen as a tag and not a keyword – Ryan Jones Feb 24 at 5:33
  • @animuson looking into it further, I am not sure that is the case. It seems to show the both oracle and blockchain as tags in each result, but oracle as a keyword on each result. And then it also provides a "equivalent_tag_search" which includes both of those results also. So I am still looking into it. – Ryan Jones Feb 24 at 7:10
8

Instead of doing the hard work to separately specify the search term (q=oracle) and tag (tagged=blockchain), just put whatever you put in the search box on the site (oracle [blockchain]) in the q parameter itself. This API call gives 66 results, just like the site search:

Fragment of the JSON result of the API call.

1
  • 1
    Thank you @Glorfindel . This is super useful. I had not come across this in the documentation when working with tags and keywords together using the API. Problem solved. – Ryan Jones Feb 24 at 9:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .