Create sql for text search