3

Entering "comprehension" [-list-comprehension] in the search box results in the following url : https://stackoverflow.com/search?q=x%22comprehension%22+[-list-comprehension] and on the right hand side bar the following is displayed:

posts containing

"comprehension"

within these tags not list-comprehension

So far things are correct. However all the question that do have the list-comprehension tag, the exact opposite of what the result should have been. Can you please fix this?

3 Answers 3

1

We now support this, as long as the negative tag isn't the only thing in your search. Also note that the - should precede the tag entirely, rather than be inside.

Here's your search: "comprehension" -[list-comprehension]
...and just to show the exclude is working, here it is without the negative tag: "comprehension"

2

Unfortunately this behaviour is by design.

For performance reasons, the tag-based NOT operator is disallowed when supplying a single tag. This is because the set of questions without a single tag is a huge set of questions. So the system makes you specify a second tag to bound the results (i.e., search for all questions with tag1, but don't also have tag2). In the disallowed case, the system simply flips the logic on the single tag so the result set is guaranteed to be bounded.

As you saw, the system correctly interpreted your intentions, but the input transformation isn't obvious.

Note also that even when specifying -, the tag with the NOT cannot appear as the first tag in the sequence.

1

Since the - operator is undocumented, it's hard to say if the bug is in how the search is working or in how the sidebar is interpreting the results.

Using the Google search box with "comprehension" -list-comprehension seems to work.

You must log in to answer this question.

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