Why does this search for [help/dont-ask] return irrelevant results in DSE?

85 Views Asked by At

Why does this ridiculously simple query on data.stackexchange.com return results that don't have [help/dont-ask] in the comment text? I feel like I'm missing something mind-numbingly obvious here.

select top 10 Id, PostId, Text
from comments
where text like '%[help/dont-ask]%'

Results I currently get:

Id  PostId  Text
--  ------- -----------------------------------
1   35314   not sure why this is getting downvoted -- it is correct! Double check it in your compiler if you don't believe him!
2   35314   Yeah, I didn't believe it until I created a console app - but good lord!  Why would they give you the rope to hang yourself!  I hated that about VB.NET - the OrElse and AndAlso keywords!
4   35195   I don't see an accepted answer now, I wonder how that got unaccepted. Incidentally, I would have marked an accepted answer based on the answers available at the time. Also, accepted doesn't mean Best :)
9   47239   Jonathan: Wow!  Thank you for all of that, you did an amazing amount of work!
10  45651   It will help if you give some details of which database you are using as techniques vary.
12  47428   One of the things that make a url user-friendly is 'discover-ability', meaning you can take a guess at url's simply from the address bar. http://i.love.pets.com/search/cats+dogs could easily lead to http://i.love.pets.com/search/pug+puppies etc
14  47481   I agree, both CodeRush and RefactorPro are visually impressive (most of which can be turned off BTW), but for navigating and refactoring Resharper is much better in my opinion of using both products.
15  47373   Just wanted to mention that this is an excellent solution if you consider the problem to be linear (i.e. treating `A1B2` as a single number). I still think the problem is multi-dimensional, but I guess we'll just have to wait for the author to clarify :)
16  47497   Indeed, the only way to do this is get the server to generate your CSS file which can be done in many ways depending on which language you are using. HttpHandlers are common in C#.  You could use jQuery or the likes to add styling to every element with the class 'ourColur' and parametrise your JS
18  47513   This advice goes against the spirit of CSS, which is separation of content and presentation. You way requires changing HTML for presentation sake, and stating in content which elements have same color.

...none of which contains the magic link (or even the text dont-ask).

1

There are 1 best solutions below

1
On BEST ANSWER

Because [] delimits a set of characters to find.

You need to escape them.

Or just use CHARINDEX as the search is unsargable anyway.

WHERE CHARINDEX('[help/dont-ask]', text) > 0