I am trying to get a full text search on a mysql database. The problem is that some of the fields can be left null. For example I have a basic address table with columns
StreetLine1
StreetLine2
City
State
Zip
Now none of these are going to be required so any one of them could be null. When I do my full text search
SELECT *, (MATCH (StreetLine1, StreetLine2, City, State, Zip) AGAINST ('+{0}*' IN BOOLEAN MODE)) AS Relevance FROM Address HAVING Relevance > 0 Order By Relevance Desc
{0} is just a placeholder
If none of the fields are null it works great. But if one of them is null the row is not returned.
I figured I should just create a view so I did but then I could not figure out how to add the full text index to that view
Any suggestions?
These fields are FAR too small for full text search to be what you want to do. Plus, you have to make your tables MyIsam, which is generally less suitable than InnoDb.
You want to use the
LIKEoperator here.