lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "K, Baraneetharan" <>
Subject How to loop through the DataImportHandler query results?
Date Thu, 16 Feb 2012 11:53:42 GMT

Hi Solr community,

I'm new to Solr and DataImportHandler., I've a requirement to fetch the data from a database
table and pass it to solr.

Part of existing data-config.xml and solr schema.xml are given below,


    <dataSource driver="com.mysql.jdbc.Driver" url="jdbc:mysql://" user="XXXX"
password="1234" />
    <document name="sample">
        <entity name="adaptation" pk=" sample _id"
          query="Select * from adap"
         transformer="TemplateTransformer,DateFormatTransformer" >

         <field column="field_mrmid_value" name="mrm_id_camp_s_t" />
         <field column="field_ sample _scope_value" name=" sample _scope_camp_s_s" />
         <field column="field_quarterly_plan_value" name="quarterly_plan_camp_s_s" />
         <field column="field_business_unit_value" name="field_business_unit_value_camp_s_t"
         <field column="field_sub_business_value" name="field_sub_business_value_camp_s_t"
         <field column="field_cdescription_value" name=" sample _description_camp_s_t"
        <field column="field_ sample _owner_value" name=" sample _owner_camp_s_s" />



<schema name="example" version="1.2">
   <dynamicField name="*_camp_m_i"  type="int"    indexed="true"  stored="true" multiValued="true"/>
   <dynamicField name="*_camp_s_i"  type="int"    indexed="true"  stored="true" multiValued="false"/>
   <dynamicField name="*_camp_m_t"  type="text"    indexed="true"  stored="true" multiValued="true"/>
   <dynamicField name="*_camp_s_t"  type="text"    indexed="true"  stored="true" multiValued="false"/>
   <dynamicField name="*_camp_m_s"  type="string"  indexed="true"  stored="true" multiValued="true"/>
   <dynamicField name="*_camp_s_s"  type="string"  indexed="true"  stored="true" multiValued="false"/>
   <dynamicField name="*_camp_m_l"  type="long"  indexed="true"  stored="true" multiValued="true"/>
   <dynamicField name="*_camp_s_l"  type="long"  indexed="true"  stored="true" multiValued="false"/>

The table used in the query (adap) is often modified, number of columns in this table are
changing frequently. Hence we are supposed to change the data-config.xml whenever a field
is added or deleted.
To avoid that we don't want to mention the column names in the field tag , but want to write
a query to map all the fields in the table with solr fileds even if we don't know, how many
columns are there in the table.  I need a kind of loop which runs through all the query results
and map that with solr fileds.

Please help me.


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message