views:

657

answers:

4

There is a request to make the SO search default to an AND style functionality over the current OR when multiple terms are used.

The official response was:

not as simple as it sounds; we use SQL Server 2005's FREETEXT() function, and I can't find a way to specify AND vs. OR -- can you?

So, is there a way?

There are a number of resources on it I can find, but I am not an expert.

+2  A: 

As far as I've seen, it is not possible to do AND when using FREETEXT() under SQL 2005 (nor 2008, afaik).

A FREETEXT query ignores Boolean, proximity, and wildcard operators by design. However you could do this:

WHERE FREETEXT('You gotta love MS-SQL') > 0
 AND FREETEXT('You gotta love MySQL too...') >  0

Or that's what I think :)

-- The idea is make it evaluate to Boolean, so you can use boolean operators. Don't know if this would give an error or not. I think it should work. But reference material is pointing to the fact that this is not possible by design.

The use of CONTAINS() instead of FREETEXT() could help.

Martín Marconcini
+1  A: 

The answer over here claims it's not possible.

Sören Kuklau
+1  A: 

I just started reading about freetext so bear with me. If what you are trying to do is allow searches for a tag, say VB, also find things tagged as VB6, Visual Basic, VisualBasic and VB.Net, wouldn't those values be set as synonyms in the DB's Thesaurus rather than query parameters?

If that is indeed the case, this link on MSDN explains how to add items to the Thesaurus.

Rob Allen
+1  A: 

OK, this change is in -- we now use CONTAINS() with implicit AND instead of FREETEXT() and its implicit OR.

Jeff Atwood