title: Magento solr search - how to add custom field to product search index
body: <p>I have enterprise magento 1.10 and I need to add custom field to solr index in order to to have better search results. This custom field should contain category names for indexed product.</p>
  
  <p>I need to know which part of magento I need to amend. I modified method Enterprise_Search_Model_Resource_Index::_getCatalogCategoryData which actualy produces some category related data but my new field doesnt appear in message to sorl.  </p>
  
  <p>Have I miss something?</p>
  
  <p>Also I have some notes here, maybe it would someone help <a href="http://docs.nostresscommerce.com:8090/pages/viewpage.action?pageId=2490371" rel="nofollow">http://docs.nostresscommerce.com:8090/pages/viewpage.action?pageId=2490371</a></p>
  
  <p>My output of rewrited Enterprise_Search_Model_Resource_Index::_getCatalogCategoryData, and I need category_name_level_* in solr.</p>
  
  <pre><code>  [result] =&gt; Array
          (
              [12227] =&gt; Array
                  (
                      [#categories] =&gt; Array
                          (
                              [0] =&gt; 2
                              [3] =&gt; 3235
                              [7] =&gt; 2765
                              [10] =&gt; 6672
                          )
  
                      [#show_in_categories] =&gt; Array
                          (
                              [1] =&gt; 6671
                              [2] =&gt; 6670
                              [4] =&gt; 3224
                              [5] =&gt; 3199
                              [6] =&gt; 3191
                              [8] =&gt; 2761
                              [9] =&gt; 2760
                          )
  
                      [#position_category_2] =&gt; 1
                      [#position_category_6671] =&gt; 120000
                      [#position_category_6670] =&gt; 120000
                      [#position_category_3235] =&gt; 0
                      [#position_category_3224] =&gt; 150000
                      [#position_category_3199] =&gt; 150000
                      [#position_category_3191] =&gt; 120000
                      [#position_category_2765] =&gt; 1
                      [#position_category_2761] =&gt; 250001
                      [#position_category_2760] =&gt; 250001
                      [#position_category_6672] =&gt; 0
                      [#visibility] =&gt; 4
                      [#category_name_level_1] =&gt; Array
                          (
                              [0] =&gt; BCC Root Category
                          )
  
                      [#category_name_level_4] =&gt; Array
                          (
                              [0] =&gt; Huishouden
                              [1] =&gt; Top wasmachines
                              [2] =&gt; Accessoires wasmachine
                          )
  
                      [#category_name_level_3] =&gt; Array
                          (
                              [0] =&gt; Beste Koop Shop
                              [1] =&gt; Top
                              [2] =&gt; Wasmachine
                          )
  
                      [#category_name_level_2] =&gt; Array
                          (
                              [0] =&gt; Acties
                              [1] =&gt; Speciale informatie pagina's
                              [2] =&gt; Huishouden
                          )
  
                      [#category_name_level_5] =&gt; Array
                          (
                              [0] =&gt; Wasmachines
                          )
  
                  )
  
          )
  </code></pre>
  
  <p>Thanks a lot,
  Jaro.</p>
  
  <p>I found a solution</p>
  
  <pre><code>class Xyz_Solrsearch_Model_Resource_Engine extends Enterprise_Search_Model_Resource_Engine {
      public function __construct()
      {
          $this-&gt;_advancedDynamicIndexFields[] = '#category_name_level_';
          parent::__construct();
      }
  }
  </code></pre>