title: Mapping items with multiple rows from mysql to solr
body: <p>So I have a normalized table with some data that I want to put into a Solr index, something akin to this</p>
  
  <pre><code>+----+--------------+--------------+---------+
  | id |     name     |  attribute   | value   |
  +----+--------------+--------------+---------+
  |  1 | Apple        | color        | green   |
  |  1 | Apple        | shape        | round   |
  |  1 | Apple        | origin       | Belgium |
  |  2 | Motorbike    | type         | fast    |
  |  2 | Motorbike    | nr of wheels | 2       |
  |  3 | Office chair | color        | grayish |
  |  3 | Office chair | spins        | yes     |
  +----+--------------+--------------+---------+
  </code></pre>
  
  <p>Now, I would prefer to have it to be indexed as one document per unique id (i.e. item). But then I will have to consolidate n attributes into a single document. To do this I would need to do some magic with my dataConfig. But how can I store and map n fields? Is this the right time to use dynamic fields?</p>
  
  <p>Here is my current try. I'm pretty sure it's not valid.</p>
  
  <pre><code>&lt;dataConfig&gt;
      &lt;dataSource 
          type="JdbcDataSource" driver="com.mysql.jdbc.Driver"
          url="jdbc:mysql://localhost/mystuff"
          user="root" password="*****"/&gt;
  
      &lt;document name="doc"&gt;
          &lt;entity name="t1" query="select * from item_to_id_table"&gt;
              &lt;field name="id" column="id"/&gt;
              &lt;field name="name" column="name"/&gt;
              &lt;entity name="t2" query="select * from my_flat_table" 
                      cacheKey="t1.id"
                      cacheLookup="t2.id"&gt;
  
                  &lt;!-- alt 1 --&gt;
                  &lt;field name="$(t2.attribute)" column="value" /&gt;
                  &lt;!-- alt 2 --&gt;
                  &lt;entity name="properties" query="select property, value from t2" 
                          cacheKey="$(t2.attribute)"
                          cacheLookup="property"&gt;
                      &lt;field name="$(properties.property)" column="value" /&gt;
                  &lt;/entity&gt;
              &lt;/entity&gt;
          &lt;/entity&gt;
  
      &lt;/document&gt;
  &lt;/dataConfig&gt;
  </code></pre>
  
  <p>I'm pretty sure neither of the two alternatives are valid, I'll try them out soon unless I can figure out something better. Perhaps a script transform as a third alternative.</p>
  
  <p>Is this use case reasonable to use with Solr?</p>