Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8731981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:21:21+00:00 2026-06-13T09:21:21+00:00

So I have a normalized table with some data that I want to put

  • 0

So I have a normalized table with some data that I want to put into a Solr index, something akin to this

+----+--------------+--------------+---------+
| 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     |
+----+--------------+--------------+---------+

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?

Here is my current try. I’m pretty sure it’s not valid.

<dataConfig>
    <dataSource 
        type="JdbcDataSource" driver="com.mysql.jdbc.Driver"
        url="jdbc:mysql://localhost/mystuff"
        user="root" password="*****"/>

    <document name="doc">
        <entity name="t1" query="select * from item_to_id_table">
            <field name="id" column="id"/>
            <field name="name" column="name"/>
            <entity name="t2" query="select * from my_flat_table" 
                    cacheKey="t1.id"
                    cacheLookup="t2.id">

                <!-- alt 1 -->
                <field name="$(t2.attribute)" column="value" />
                <!-- alt 2 -->
                <entity name="properties" query="select property, value from t2" 
                        cacheKey="$(t2.attribute)"
                        cacheLookup="property">
                    <field name="$(properties.property)" column="value" />
                </entity>
            </entity>
        </entity>

    </document>
</dataConfig>

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.

Is this use case reasonable to use with Solr?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T09:21:22+00:00Added an answer on June 13, 2026 at 9:21 am

    I solved this the way described here.

    In short I used a script transform to turn the ‘properties’ entity rows into fields with a prefix, “p_”. Somewhat like this (example code, there may be bugs):

    <dataConfig>
        <dataSource 
            type="JdbcDataSource" driver="com.mysql.jdbc.Driver"
            url="jdbc:mysql://localhost/mystuff"
            user="root" password="*****"/>
    
        <script>
        <![CDATA[ 
        function formProperty(row) { 
          var propName = row.get("property");
          var propVal = row.get("value");
          var fieldName = "p_" + propName;
          row.put(fieldName,propVal);
          return row; 
        } 
        ]]>
        </script> 
    
        <document name="doc">
            <entity name="t1" query="select * from item_to_id_table">
                <field name="id" column="id"/>
                <field name="name" column="name"/>
                <entity name="t2" 
                        query="select * from my_flat_table
                        where my_flat_table.id = ${t1.id}"
                        transformer="script:formProperty">
                </entity>
            </entity>
        </document>
    </dataConfig>
    

    I then mapped them into the solr schemata in schema.xml as dynamic fields

    <dynamicField name="p_*" indexed="true" stored="true" type="string"/>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table with some duplicate rows that I want to normalize into
Here is the problem. I have a stored procedure that transforms normalized data into
I have a REST service that returns a collection that contains non- normalized data.
I've got an SQL table that I use to keep product data. Some products
Alright, I have done some research and found out that a good normalized articles
I have input data in a flattened file. I want to normalize this data,
I currently have a table of 3m records that needs updating nightly. The data
I have a table in mysql which is not normalized and I need to
edit: my table schema below is poorly normalized as suggested and I have revamped
I have a range of tables that I have normalized for a user profile

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.