title: Umbraco: media node's path (all node IDs path, not file path defined as umbracoFile) does not always contain all ancestors
body: <p>I am currently accessing the path attribute of a media node (in order to index its ancestor for PDF full index search, but that's not necessary to know for this question), and I'm quite surprised to find that not all ancestors are actually listed in the comma-delimited list of all ancestors!</p>
  
  <p>For example, if I've got a media tree like the following:</p>
  
  <p>-Media Group 1 (id: 123)</p>
  
  <ul>
  <li><ul>
  <li>Sub Group 1 (id: 234)</li>
  </ul></li>
  <li><ul>
  <li><ul>
  <li>some-pdf.pdf (id: 334)</li>
  </ul></li>
  </ul></li>
  </ul>
  
  <p>-Media Group 2 (id: 1023)</p>
  
  <ul>
  <li><ul>
  <li>Sub Group 1 (id: 1234)</li>
  </ul></li>
  <li><ul>
  <li><ul>
  <li>some-other-pdf.pdf (id: 1334)</li>
  </ul></li>
  </ul></li>
  </ul>
  
  <p>I would expect that the path for some-pdf.pdf would be { -1, 234, 123} and some-other-pdf.pdf to be {-1, 1023, 1234 } but what I'm finding is that surprisingly often, the grandparents aren't present! For example, some-pdf.pdf would be { -1, 234 } and some-other-pdf.pdf is { -1, 1234 }.</p>
  
  <p>This is particularly problematic because I need to know what the Media Group is as a client requires that a search can be filtered by the group (meaning the level 1 folder for each PDF in meda).</p>
  
  <p>Is this particular to my installation for some reason or is it really that I can't rely on "path" to be accurately containing all ancestors, particularly the first level ones?</p>
  
  <p>Thanks in advance,</p>
  
  <p>Ted</p>
  
  <p>UPDATE:</p>
  
  <p>Maybe the context does matter more than I thought: it appears that while the complete ancestor path is indeed in the database (as expected), for some reason it's not available in the context I need it in:</p>
  
  <pre><code>    private void Indexer_GatheringNodeData(object sender, IndexingNodeDataEventArgs e)
      {
          //Log.Add(LogTypes.Debug, 0, "PDFIndexer node indexed.");
  
          var node = e.Node;
  
          if (node.HasAttributes)
         {
              var path = node.Attribute("path").Value;
  </code></pre>
  
  <p>...</p>
  
  <p>For some reason the path attribute at this point is (only sometimes) incomplete as described above.</p>