Wondering if there is any way to force Craft to update the search index for an entry when it is saved.

Reason I ask is that on our site we have a Location entry type with lat/lon inputs that we use to maintain store locations and plot them on a map. However, when we update the lat/lon coordinates, it does not update the search index and continues to plot the old location on the map even though it is displaying the new address in the text.

We can force it to update by rebuilding the search indexes, the only downside is that it takes a few minutes and renders the site search functions useless until it is done. If there's some way for the entry to automatically update the index when lat/lon coordinates are changed, that would be awesome. Any ideas?

  • What type of field are you storing the lat/long values in?
    – Brad Bell
    Commented Dec 11, 2015 at 0:52
  • Each one has a number field with 6 decimal points.
    – Joel
    Commented Dec 11, 2015 at 16:14

2 Answers 2


You can do a task resave after elements are entered:

public function resaveElements()
    // Queue up a new ResaveElements task
    craft()->tasks->createTask('ResaveElements', null, array(
        'elementType' => ElementType::Entry,
        'criteria'    => array('section' => 'search', 'limit' => null, 'status' => null,'localeEnabled' => null)

    // Start running tasks

Craft has always updated the search index automatically after an entry is saved.

The exact time it does that depends on what version of Craft you are using, and how the entry is being saved (web or CLI), but generally speaking there should never be a need to manually or programmatically update the search index yourself after saving an entry.

  • Does it have to be a control panel request to run the task? Because I've built a little front-end "control-panel" and I'm not sure if it runs. Commented Jun 28, 2021 at 14:43
  • 1
    By default the queue will only be run for control panel requests. You can “fix” that by creating a cron job that runs the craft queue/run command every minute or so. Commented Jun 28, 2021 at 19:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.