Answers.Body: <p>This is what I ended up with which works great for me. </p>
  
  <pre><code>$ses = craft()-&gt;assetIndexing-&gt;getIndexingSessionId(); 
  $src = craft()-&gt;assetIndexing-&gt;getIndexListForSource($ses, 7); 
  
  for ($i = 1; $i &lt;= $src['total']; $i++) { 
      craft()-&gt;assetIndexing-&gt;processIndexForSource($ses, $i, 7); 
  }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-07-23T13:24:57.543Z
Answers.LastActivityDate: 2016-07-23T13:24:57.543Z
Answers.UserDisplayName: Trevor Orr
Body: <p>I am trying to update an asset index from a plugin but can't seem to get it to work.  Looking at the docs this seems to me like it should work but it does not. I am on the right path here?</p>
  
  <pre><code>$ses = craft()-&gt;assetIndexing-&gt;getIndexingSessionId();
  craft()-&gt;assetIndexing-&gt;processIndexForSource($ses, null, 7);
  </code></pre>
  
  <p>7 is the id of the asset folder I want to re-index.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-07-22T18:55:09.587Z
Comments.Text: My guess is you're missing `craft()->assetIndexing->getIndexListForSource($sessionId, $sourceId);`. Check how the Asset Index Tool does it in `craft/app/tools/AssetIndexTool.php`.
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-07-22T20:53:42.270Z
Comments.Text: You are correct. I was not using it quite right and not understanding exactly how it worked.  This is what I ended up with which works great for me.
  
    $ses = craft()->assetIndexing->getIndexingSessionId();
    $src = craft()->assetIndexing->getIndexListForSource($ses, 7);
    
    for ($i = 1; $i <= $src['total']; $i++) {
     craft()->assetIndexing->processIndexForSource($ses, $i, 7);
    }
Comments.UserDisplayName: Trevor Orr
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-07-23T00:23:05.573Z
Comments.Text: Awesome glad you got it sorted!  Mind adding that as an official answer instead of a comment? Easier for other people that might have the same question to find.
Comments.UserDisplayName: Brad Bell
Tags: <assets><index>
Title: How do you programmatically update an asset index?
ThreadText: # How do you programmatically update an asset index?
  
  (Asked by: username_0 on 2016-07-22)
  
  I am trying to update an asset index from a plugin but can't seem to get it to work. Looking at the docs this seems to me like it should work but it does not. I am on the right path here?
  
  ```
  $ses = craft()->assetIndexing->getIndexingSessionId();
  craft()->assetIndexing->processIndexForSource($ses, null, 7);
  
  ```
  
  7 is the id of the asset folder I want to re-index.
  
  **Tags:** assets, index
  
  > **Comments:**
  > **username_1**: My guess is you're missing `craft()->assetIndexing->getIndexListForSource($sessionId, $sourceId);`. Check how the Asset Index Tool does it in `craft/app/tools/AssetIndexTool.php`.  
  > **username_0**: You are correct. I was not using it quite right and not understanding exactly how it worked.  This is what I ended up with which works great for me.    $ses = craft()->assetIndexing->getIndexingSessionId();   $src = craft()->assetIndexing->getIndexListForSource($ses, 7);      for ($i = 1; $i <= $src['total']; $i++) {    craft()->assetIndexing->processIndexForSource($ses, $i, 7);   }  
  > **username_1**: Awesome glad you got it sorted!  Mind adding that as an official answer instead of a comment? Easier for other people that might have the same question to find.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2016-07-23. Score: 3
  
  This is what I ended up with which works great for me.
  
  ```
  $ses = craft()->assetIndexing->getIndexingSessionId(); 
  $src = craft()->assetIndexing->getIndexListForSource($ses, 7); 
  
  for ($i = 1; $i <= $src['total']; $i++) { 
      craft()->assetIndexing->processIndexForSource($ses, $i, 7); 
  }
  
  ```
  
  
  ---
  
  