Answers.Body: <p>Craft has always updated the search index automatically after an entry is saved.</p>
  
  <p>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.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-06-28T14:43:44.087Z
Answers.Text: 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.
Answers.UserDisplayName: Dominik Krulak
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-06-28T19:56:39.343Z
Answers.Text: 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.
Answers.UserDisplayName: Brandon Kelly
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-02-18T11:35:12.950Z
Answers.LastActivityDate: 2020-02-18T11:35:12.950Z
Answers.UserDisplayName: Brandon Kelly
Answers.Body: <p>You can do a task resave after elements are entered:</p>
  
  <pre><code>public function resaveElements()
  {
      // Queue up a new ResaveElements task
      craft()-&gt;tasks-&gt;createTask('ResaveElements', null, array(
          'elementType' =&gt; ElementType::Entry,
          'criteria'    =&gt; array('section' =&gt; 'search', 'limit' =&gt; null, 'status' =&gt; null,'localeEnabled' =&gt; null)
      ));
  
      // Start running tasks
      craft()-&gt;tasks-&gt;runPendingTasks();
  }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-12-22T20:14:16.140Z
Answers.LastActivityDate: 2015-12-22T20:22:51.583Z
Answers.LastEditDate: 2015-12-22T20:22:51.583Z
Answers.UserDisplayName: mdxprograms
Body: <p>Wondering if there is any way to force Craft to update the search index for an entry when it is saved.</p>
  
  <p>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.</p>
  
  <p>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?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-12-11T00:52:58.227Z
Comments.Text: What type of field are you storing the lat/long values in?
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-12-11T16:14:27.073Z
Comments.Text: Each one has a number field with 6 decimal points.
Comments.UserDisplayName: Joel
Tags: <search><index>
Title: Update Search Index on Entry Save
ThreadText: # Update Search Index on Entry Save
  
  (Asked by: username_0 on 2015-12-10)
  
  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?
  
  **Tags:** search, index
  
  > **Comments:**
  > **username_1**: What type of field are you storing the lat/long values in?  
  > **username_0**: Each one has a number field with 6 decimal points.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2020-02-18. Score: 1
  
  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.
  
  > **Comments:**
  > **username_3**: 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.  
  > **username_2**: 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.  
  
  ---
  
  ### Answer by username_4 on 2015-12-22. Score: 1
  
  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()->tasks->runPendingTasks();
  }
  
  ```
  
  
  ---
  
  