4
votes

I've read the Sphinx documentation and various resources, but I am confused about the process of maintaining main and delta indexes. Please let me know if this is correct:

  • Have a table that partitions the search index by last_update_time (NOT id as in the tutorial http://sphinxsearch.com/docs/1.10/delta-updates.html)

  • Update the delta index every 15 minutes. The delta index only grabs records that have been updated > last_update_time:

    indexer --rotate --config /opt/sphinx/etc/sphinx.conf delta
    
  • Update the main index every hour by merging delta using:

    indexer --merge main delta --merge-dst-range deleted 0 0 --rotate
    

The pre query SQL will update last_update_time to NOW(), which re-partitions the indexes

Confusion: Will the merge run the pre query SQL?

  • After the main index is updated, immediately update the delta index to clean it up:

    indexer --rotate --config /opt/sphinx/etc/sphinx.conf delta
    

EDIT: How would deletion of records even work? Since the delta index would contain deleted records, records would only be removed from search queries after the delta index was merged into main?

2

2 Answers

2
votes

To deal with the deletes you need to take a look at the killlist, it basically defines removal criteria:

http://sphinxsearch.com/docs/manual-1.10.html#conf-sql-query-killlist

In an example I have we build our main daily, early morning then simply run a delta update (including the killlist) every 5 minutes.

On the merge stuff, I'm not sure as I've never used it.

0
votes

This is only half of the job. Deleted stuff must be taken care by kill list (kbatch now it is called) and then delta will not show the deleted results. But if you merge - they will reappear. To fix this - you have to do

indexer --merge main delta --merge-dst-range deleted 0 0 --rotate

But in order for this to work - you need an attribute "deleted" to be added to every result that was deleted. Then merge process will filter out results that have deleted=1 and main index will not have deleted results in it.