I scanned dozens of articles and forum threads, looked through official documentation, but couldn't find an answer. This article sounds promising, since is says that The data to be indexed can generally come from very different sources: SQL databases, plain text files, HTML files
, but unfortunately as all other articles and forum threads it is devoted to MySQL
.
It is rather strange to hear that Sphinx
is so cool, it can do this and that, it can do practically anything you want with any data source you like. But where are all those examples with data sources other than MySQL
? Just one tiniest and trivial step-by-step example of Sphinx
configuration when you want to scan the easiest source of data in the world - plain text files. Let's say, I've installed Sphinx
and want to scan my home directory (recursively) to find all plain text files, containing "Hello world". What should I do to implement this?
Prerequisites:
Ubuntu
sudo apt-get install sphinxsearch
- ... what is next????
Have a look at this before proceeding Sphinx without SQL! .
Ideally I would do this.
We are going to use Sphinx's sql_file_field to index a table with file path. Here is the PHP script to create a table with file path for a particular directory(scandir).
Below code is sphinx.conf file to index the table with filepath. Notice sql_file_field which will index those files which are specified in the text(filepath) column
After creating table, saving the sphinx.conf in /etc/sphinxsearch/sphinx.conf just run sudo indexer filename --rotate, your indexes are ready! Type search and then keyword to get results.