Bobbake4
Bobbake4

Reputation: 24857

How to properly reindex Sphinx search server?

I have a website that is using Sphinx search server to search through a MySQL database. This is working perfectly but the issue is when new items are added to the database. My question is when is the best time to perform a reindex as well as how to do it correctly. Currently I am doing a "indexer --all --rotate" but this doesn't seem to be working. The only way to update the indexes is to stop sphinx then perform a indexer --all and then restart the service. This is obviously not ideal on a live site. If anyone has any information on how to do this correctly I would really appreciate it.

Thanks

Upvotes: 0

Views: 6423

Answers (2)

amyd
amyd

Reputation: 7

The '--rotate' option rotates the index, i.e. create a temporary copy of each index and replace the old ones when finished. It creates a second index, parallel to the first(in the same place, simply including .new in the filenames). Once complete, indexer notifies searchd via sending the SIGHUP signal, and searchd will start serving from the newer files having .new extention. If .new files are already present in the system, it just update them after using '--rotate' option.

The '--all' option tells indexer to update every index but not the second indexer files having extension .new which are created using '--rotate' option

Upvotes: 0

0x4a6f4672
0x4a6f4672

Reputation: 28245

If I understand it correctly, a restart should not be necessary. The -all option tells indexer to update every index. -rotate rotates the index, i.e. create a temporary copy of each index and replace the old ones when finished. According to the Sphinx manual rotating works as follows: "it creates a second index, parallel to the first (in the same place, simply including .new in the filenames). Once complete, indexer notifies searchd via sending the SIGHUP signal, and searchd will attempt to rename the indexes (renaming the existing ones to include .old and renaming the .new to replace them), and then start serving from the newer files. Depending on the setting of seamless_rotate, there may be a slight delay in being able to search the newer indexes."

There are differences between seamless and "interrupted" rotates. The type can be controlled using the seamless_rotate parameter in the Sphinx config file. Seamless rotates come at the cost of higher peak memory usage during the rotation, but happen without interruption.

The Sphinx version also matters. In former versions a restart was required to update the index, in the newest version this seems to be no longer necessary.

Upvotes: 2

Related Questions