36

tl;dr: Give the score search operator ability to change between greater than and less than.

I just noticed that searching for score:0 turns up only question with a score equal to 0. Searching for score:1 gives everything with a positive score. (>=1)

I can live with these. But here's the big one: score:-1.

I would expect it to give all the negatively scored posts - there is a minus sign in there.

But it doesn't. It gives all the posts >=-1. Greater than?

So, my is that we get more granular search options for score.

For example,

  • score:1 would show all posts with score == 1
  • score:1+ would show everything score >= 1
  • score:0 would show all posts with score == 0
  • score:-1 would show everything score == -1
  • score:-1- would show al posts where score <= -1

In short, the operator after the number would show which direction to go with the matching. A minus sign means less than, a plus sign means greater than. No sign means exact.

3 Answers 3

34

We use the Google number range style here which is simple: term:<min>..<max> where either min or max are optional as well. Here are some examples:

  • score:-2..2 means -2 to 2
  • score:..2 means <= 2
  • score:2..2 means == 2
  • score:-2.. means >= -2

I agree it's not obvious since score: 2 means >= 2, but I was not going to break an existing known syntax when adding the ability to search ranges as well.

6
  • I would have thought you add the [status-bydesign] tag.
    – juergen d
    Commented Jul 14, 2013 at 16:07
  • @juergend there's a feature request in there...it's just already been completed in a different way. Programmers will argue about search syntax all day, so we just choose the best route we could: match google.
    – Nick Craver Mod
    Commented Jul 14, 2013 at 16:09
  • 3
    Are you sure the last option works? score:1203..1500 works nicely, but score:1203.. gives 143,826 results...?
    – Arjan
    Commented Jul 14, 2013 at 17:21
  • @Arjan it did, will look at the bug next time I'm at a comp
    – Nick Craver Mod
    Commented Jul 14, 2013 at 22:09
  • 2
    @Arjan yep there was a bug that creeped in, all fixed now - same range operator works on dates now as well (the optional part didn't before).
    – Nick Craver Mod
    Commented Jul 14, 2013 at 23:15
  • This is not really documented, other than in the January announcement, right? Should we create a "How does search work"?
    – Arjan
    Commented Jul 15, 2013 at 6:38
15

Use score:..-1 to search for posts having a score of -1 or lower.

And searching for an exact score: I don't know a use case where that one is helpful.

4
  • 10
    Yeah, that's totally obvious. Who wrote the grammar for this search algorithm? Commented Jul 14, 2013 at 14:33
  • 7
    That should be on the advanced search page.
    – Undo
    Commented Jul 14, 2013 at 14:33
  • @RichardJ.RossIII Oded, obviously. Bots aren't known for their excellent grammar.
    – Undo
    Commented Jul 14, 2013 at 14:34
  • @RichardJ.RossIII The range operator was borrowed from Google, where the unbounded lower range is simply an extension of that.
    – Tim Stone
    Commented Jul 14, 2013 at 15:30
6

As @juergen d already said you can use option score:..-1 to search posts having score of -1 or lower.

In addition search engine allow to combine several score options in one search, e.g., for example, you can use request score:..-1 score:-1 to search posts having exact score -1 (e.g. -1 and lower and -1 and greater at same time).

Also, using option combination you can receive some complex search results, for example score:32 score:..34 give posts with score from 32 to 34.

1
  • 6
    As a side note, you can combine it into a single option as score:32..34
    – Tim Stone
    Commented Jul 14, 2013 at 15:29

You must log in to answer this question.

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