26

One of my favourite ways to find unanswered but well asked questions is by using the query:

[tag] answers:0 score:n

Where n is some positive integer. I then sort by newest and look for questions I can help with.

The problem with this query is that I find a lot of questions that have been answered via a back and forth discussion in the comments

Putting aside the fact that these questions should have a real answer, what I would really like in search is a way to get rid of this noise and find those that have been completely ignored: No Answers, No Comments, and a positive score. Is this doable?

It seems like the query is available through this API: https://api.stackexchange.com/docs/advanced-search, but putting variations on comment_count:0 in the url for the site proper does not seem to work.

11
  • You can use Data Explorer like so, but the data may be up to a week old. Otherwise, write a script that retrieves questions using the API search capability, and then drops those with comments_count>0.
    – user3717023
    Commented Mar 31, 2016 at 22:12
  • @404 Can u give the option to edit tag also in that query.
    – Sandeep
    Commented Apr 1, 2016 at 5:35
  • 3
    If a comment gives the answer, ideally, someone should repost it as an actual answer. Note that just because there are comments, does not mean that one of them is an answer.
    – Laurel
    Commented Apr 1, 2016 at 15:31
  • 8
    This seems meta^2- is one of the earlier comments here the answer?
    – beirtipol
    Commented Apr 1, 2016 at 17:43
  • @404 unfortunately the "week old" issue makes the first solution tricky. Most of the ones I checked have an answer by the time the query runs (it is still useful if I exclude more recent results, so kudos). As for the second, I would prefer an in-browser solution if one is available
    – Chris
    Commented Apr 1, 2016 at 17:57
  • Maybe you can do something with the tumbleweed badge.
    – nwp
    Commented Apr 1, 2016 at 18:02
  • @nwp Clever - the question that the badge was awarded for doesn't seem to be a part of the query schema though, which is strange since your link clearly associates the two
    – Chris
    Commented Apr 1, 2016 at 18:08
  • @nwp Not for positively scored posts, which is what OP is looking for.
    – user3717023
    Commented Apr 1, 2016 at 18:08
  • @Chris Not really strange: criteria for badges are implemented in server side code that is entirely different from the search engine.
    – user3717023
    Commented Apr 1, 2016 at 18:09
  • 1
    Related: Filter questions by number of comments Commented Apr 1, 2016 at 20:12
  • 1
    Find hot unanswered questions in your area
    – Pekka
    Commented Jun 5, 2016 at 12:18

1 Answer 1

8

The following userscript leverages the Advanced/search API of the StackAPI to get an in initial result. It then uses JavaScript to filter out the unwanted rows. The qualifying rows are presented as a link.

The script does paging but the filtering doesn't allow to limit the results very much so on large tags it might take a while before all result are in.

var rows = document.getElementById('rows'),
    search = document.getElementById('search'),
    feedback = document.getElementById('feedback'),
    tag = document.getElementById('tag'),
    score = document.getElementById('score'),
    comments = document.getElementById('comments'),
    answers = document.getElementById('answers'),
    tot,
    processed;

function buildRow(item) {
  var row = document.createElement('div'),
      a = document.createElement('a');
  a.href = item.link;
  a.textContent = item.title;
  row.appendChild(a);
  rows.appendChild(row);
  }

function buildApiUrl(urlParts, queryString) {
  var url = '',
      qp,
      queryArr = [];
  
  url = urlParts.join('/');
  if (queryString !== undefined) { 
    for(qp in queryString) {
      queryArr.push(qp + '=' + queryString[qp]); 
    }
    url = url + '?' + queryArr.join('&');
  }
  return url;
}

function handleApiResponse(response, page) {
  var i, 
      resp = JSON.parse(response),
      items = resp.items;
  if (page === undefined) {
    while (rows.firstChild) {
      rows.removeChild(rows.firstChild);
    }
    page = 1;
    tot = 0;
    processed = 0;
    search.disabled = true;
  }
 
  if (items.length > 0) {
    for(i = 0; i < items.length; i = i + 1) {
      if (items[i].comment_count === parseInt(comments.value, 10) &&
          items[i].answer_count === parseInt(answers.value, 10) &&
          items[i].score === parseInt(score.value, 10) 
         ) {
        tot = tot + 1;
        buildRow(items[i]);
      }
    }
    processed = processed + items.length;
    feedback.textContent = '# results: ' + processed + ' # filtered: ' + tot;
  } else {
    if (page === 1) {
      feedback.textContent = 'no questions found';
    }
  }
  if (resp.has_more) {
    if (resp.backoff) {
      setTimeout(function() { sendRequest(page + 1); }, resp.backoff * 1000);
    } else {
      sendRequest(page + 1);
    }
  } else {
    search.disabled = false;
  }
}

function sendRequest(page) {
  var xhr = new XMLHttpRequest(),
      api = [ 'https://api.stackexchange.com',
             '2.2',
             'search',
             'advanced'], 
      qs = {
        'order':'desc',
        'sort':'activity',
        'pagesize': 100,
        'answers': parseInt(answers.value, 10),
        'tagged': tag.value,
        'site': 'stackoverflow',
        'filter': '!9YdnSHlY(',
        'key': 'I4Ll0m749uHMyBd9S74DkA(('
        };
   
  if (page !== undefined) {
    qs.page = page;
  }   
  xhr.addEventListener('load', function () {
      handleApiResponse(xhr.responseText, page);
  });

  xhr.open('GET', buildApiUrl(api, qs));
  xhr.send();
}

search.addEventListener('click', function() { sendRequest(); });
label {
  width: 100px;
  display:inline-block;
  }

div {
  margin: 10px;
  }

div.results 
{
  margin: 5px;
}

div.results div
{
  margin: 4px;
}
<div>
  <div>
  <label for="tag">Tag</label><input id="tag" type="text" value="haskell" />
  </div>
  <div>
  <label for="score">Score</label><input id="score" type="text" value="0"/>
  </div>
  <div>
  <label for="answers">Answers</label><input id="answers" type="text" value="0"/>
  </div>
  <div>
  <label for="comments">Comments</label><input id="comments" type="text" value="0"/>
  </div>
  <div>
  <button id="search">Search</button>
  </div>

</div>
<div id="result" class="results">
  <div id="feedback">No results</div>
  <div id="rows">
  </div>
</div>

1
  • @Chris sure here you go. Html file that you can store locally and then open in your browser.
    – rene
    Commented Jul 22, 2016 at 19:28

You must log in to answer this question.

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