给定以下文件路径,存储在 mysql 数据库中:
.//.git/refs/remotes/origin/HEAD
.//.git/refs/tags
.//__init__.py
.//__init__.pyc
.//forms.py
.//forms.pyc
.//models.py
.//models.pyc
.//settings.py
.//settings.pyc
.//static
.//static/css
.//static/css/all.css
.//static/images
.//static/images/bg.png
.//static/images/favicon.ico
.//static/images/pds-header-logo.png
.//static/images/pds-logo.png
.//static/images/revolver.png
.//static/js
.//static/js/all.js
.//templates
.//templates/base.html
.//templates/default.html
.//templates/overview.html
.//urls.py
.//urls.pyc
.//views.py
.//views.pyc
.//wsgi.py
.//wsgi.pyc
需要有人能够搜索路径。例如,如果用户搜索“static”,它将返回路径中带有“static”的结果:
.//static
.//static/css
.//static/css/all.css
.//static/images
.//static/images/bg.png
.//static/images/favicon.ico
.//static/images/pds-header-logo.png
.//static/images/pds-logo.png
.//static/images/revolver.png
.//static/js
.//static/js/all.js
我目前的搜索类似于:
`SELECT path FROM files WHERE path LIKE '%search%';`
有没有办法索引这个列/改进这个搜索(删除 LIKE %%),因为我在这个系统上可能有 1M+ 文件路径。请注意,文件路径可能超过 200 个字符。