ivinco
Copying Sphinx index from different server

Copying Sphinx index from different server

Sergey NikolaevSergey Nikolaev··Updated

One day I had to build one huge index. I couldn't do it on a production box, because there was little space and I decided to build the index in another temporary place and then copy it to the production. Everything was ok except one thing which seems strange to me: Sphinx remembers the place it took exceptions from during indexing and then you can't use the index in another place until you put the exceptions to the same place. So when I copied the huge index and started searchd I got:

using config file '/path/to/sphinx.conf'...
listening on all interfaces, port=3313
listening on all interfaces, port=3317
listening on UNIX socket /path/to/searchd.sock
precaching index 'idx'
WARNING: index 'idx': preload: 'synonyms': failed to open '/mnt/data1/se15.2/synonyms.txt'; NOT SERVING

I had to copy synonyms.txt from it's normal place to /mnt/data1/se15.2/synonyms.txt and after that searchd started fine. I don't know why Sphinx has this logic, just want to warn someone who would like to build an index in one place and then copy it to another.


Need help with search infrastructure? Talk to our engineering team — we've built and maintained search systems for over 15 years.

Frequently Asked Questions

Can you build a Sphinx index on one server and copy it to another?

Yes, but watch out for embedded file paths. Sphinx stores the absolute path to files like synonyms.txt and exceptions.txt inside the index at build time. When you copy the index to a new server, you must place these files at the exact same path — or searchd will refuse to serve the index with a "failed to open" warning.

Why does Sphinx fail when copying an index between servers?

Sphinx records the absolute filesystem path of exception and synonym files at indexing time. When the index is loaded on a different server where those paths don't exist, searchd logs a warning like "failed to open '/original/path/synonyms.txt'" and refuses to serve the index. Copy the referenced files to the same absolute path on the target server to fix this.

What files do you need when moving a Sphinx index between servers?

Copy all index files (.spa, .spd, .sph, .spi, .spm, .spp, .spk) plus any referenced external files like synonyms.txt, exceptions.txt, and wordforms.txt. Place external files at the exact paths used during original indexing, or rebuild the index on the target server with updated paths in sphinx.conf.