Elastic search reindexing best practice

We have found that we occasionally end up with a situation where we search for new items and they don't come back in the search results. NOTE: Usually new things populate just fine, this only happens intermittently. We are able to fix the issue by running a system reindex from admin. We'd rather not have to do this manually and I see that there is a CLI command to reindex. Is it good practice to just run a system reindex using the CLI occasionally? How often, nightly? According to the documentation[1], this sounds like a not unusual occurrence, does that seem accurate to others?

[1] Performing a system index may resolve search issues for records that have been recently created or modules that were recently enabled for search

Parents
  • Hi Brad,

    For one of our customer we implemented a weekly cron job that reindex the whole database, running on sunday evening in order to make it available on monday morning.

    Here is the code : 

    #!/bin/bash
    json=$(curl -X POST -H Cache-Control:no-cache -H "Content-Type: application/json" -d '{
        "grant_type":"password",
        "client_id":"sugar",
        "client_secret":"",
        "username":"",
        "password":"",
        "platform":"mobile"
    }' http://crm-address/rest/v10/oauth2/token)
    access_token=$(echo $json | sed "s/{.*\"access_token\":\"\([^\"]*\).*}/\1/g") \
    
    curl -X POST -H "oauth-token: $access_token" -H Cache-Control:no-cache -H "Content-Type: application/json" -d '{
        "clear_data":true
    }' http://crm-address/rest/v10/Administration/search/reindex

    Probably there is a better way to do that, but this is working as expected :-)

    Best regards,

    Enes

Reply
  • Hi Brad,

    For one of our customer we implemented a weekly cron job that reindex the whole database, running on sunday evening in order to make it available on monday morning.

    Here is the code : 

    #!/bin/bash
    json=$(curl -X POST -H Cache-Control:no-cache -H "Content-Type: application/json" -d '{
        "grant_type":"password",
        "client_id":"sugar",
        "client_secret":"",
        "username":"",
        "password":"",
        "platform":"mobile"
    }' http://crm-address/rest/v10/oauth2/token)
    access_token=$(echo $json | sed "s/{.*\"access_token\":\"\([^\"]*\).*}/\1/g") \
    
    curl -X POST -H "oauth-token: $access_token" -H Cache-Control:no-cache -H "Content-Type: application/json" -d '{
        "clear_data":true
    }' http://crm-address/rest/v10/Administration/search/reindex

    Probably there is a better way to do that, but this is working as expected :-)

    Best regards,

    Enes

Children