/usr/local/sphinx/etc/feeds.conf
, and add the following (highlighted) code:source feeds { type = xmlpipe2 xmlpipe_command = /usr/bin/php /path/to/webroot/feeds/makeindex.php xmlpipe_field = title xmlpipe_field = description xmlpipe_field = author xmlpipe_attr_timestamp = pub_date xmlpipe_attr_multi = category_id } source feeds-delta : feeds { } index feed-items { source = feeds path = /usr/local/sphinx/var/data/feed-items charset_type = utf-8 } index feed-items-delta : feed-items { source = feeds-delta path = /usr/local/sphinx/var/data/feed-items-delta } indexer { mem_limit = 64M }
indexer
on feeds-items-delta index (as root):$ /usr/local/sphinx/bin/indexer c /usr/local/sphinx/etc/feeds.conf feed-items-delta
$ /usr/local/sphinx/bin/indexer c /usr/local/sphinx/etc/feeds.conf --merge feed-items feed-items-delta
We added a second source and index definition in our Sphinx configuration file. This index acts as the delta index. We derived the delta from our main index. The syntax we used for extending the main index was:
source feeds-delta : feeds
The syntax will define a source feeds-delta
and all options will be inherited from the source feeds
. This is somewhat similar to class inheritance in OOP. We can overwrite any option in feeds-delta, extending the index works in a similar fashion.
We didn't overwrite any option in the delta source. However, we overwrote the source
and path
options in feed-items-delta index.
Next, we ran the indexer
to create delta index. This time only new feed items were fetched (in makeindex.php)
and indexed in the delta. So delta holds only the new items, while old items are held in the main index.
Following this we ran the indexer
once again, but this time the motive was to merge the delta with the main index:
$ /usr/local/sphinx/bin/indexer c /usr/local/sphinx/etc/feeds.conf --merge feed-items feed-items-delta
We used the --merge
option of the indexer
, and provided the names of feed-items
and feed-items-delta
, as destination and source indexes respectively.
Once both our main and delta indexes are configured, we will run the indexer
on delta every time we want to fetch new items, and then merge the delta with the main. We will only perform search on the main index since it will contain all the items.
We now have the index ready with us. We need a frontend to perform the search on this index. So what are we waiting for? Let's build the search form. We will give the ability to enter a search term, an author name, and select the categories. Author name and category selection will be optional.
On specifying the search term, we will run a full-text search against our index and present the search results returned by Sphinx. If author name or categories have been specified, then we will filter the search results based on the same characteristics.