Search code examples
dockersearchsphinxindexer

How to run indexer in sphinxsearch Docker container?


I'm using the macbre/sphinxsearch/ docker image. I created the dirs for volumes and I'm running the container with command:

podman run --name sphinxsearch -p 36307:36307 -v ~/podman/volumes/sphinxsearch/:/opt/sphinx/index:z -v ./sphinx.conf:/opt/sphinx/conf/sphinx.conf:z --rm macbre/sphinxsearch

and I get an error, as indexes are not created by the indexer:

WARNING: index 'test1': prealloc: failed to open /opt/sphinx/index/test1.sph: No such file or directory; NOT SERVING
FATAL: no valid indexes to serve

How should I run the indexer in this scenario?


Solution

  • Before running the searchd daemon you firstly need to build indexes. For this purpose run the first indexer job through the container:

    podman run -v $VOLPATH/sphinxsearch/index/:/opt/sphinx/index:z \
    -v $VOLPATH/sphinxsearch/sphinx.conf:/opt/sphinx/conf/sphinx.conf:z \
    --rm macbre/sphinxsearch indexer --all --config /opt/sphinx/conf/sphinx.conf
    

    Later, when the container is already working, you can refresh indexes with:

    podman exec -it sphinxsearch indexer --rotate --all --config /opt/sphinx/conf/sphinx.conf

    I also documented the whole procedure in the post: Running SphinxSearch in Podman container

    Thanks @Manticore-Search and @macbre for pointing the direction.