Page 1 of 1

Create index on two unrelated table in Solr

Posted: Thu Nov 17, 2011 12:36 am
by jawedshamshedi
I want to create index between two tables, stock and auction. Basically I am working on a product site. So I have to create index on both tables. and they are not related at all.

In data-config.xml, that I created to create index, I wrote the following code

Code: Select all

<dataConfig>
    <dataSource type="JdbcDataSource" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost/database" user="root" password=""/>
    <document name="content">
        <entity name="stock" query="select ST_StockID,ST_StockCode,ST_Name,ST_ItemDetail from stock where estatus = 'Active' limit 100">
            <field column="ST_StockID" name="stock_ST_StockID" />
            <field column="ST_StockCode" name="stock_ST_StockCode" />
            <field column="ST_Name" name="stock_ST_Name" />
            <field column="ST_ItemDetail" name="stock_ST_ItemDetail" />
        <entity name="auction" query="select iauctionid,rad_number,vsku,auction_code from auction limit 100">
            <field column="iauctionid" name="auction_iauctionid" />
            <field column="rad_number" name="auction_rad_number" />
            <field column="vsku" name="auction_vsku" />
            <field column="auction_code" name="auction_auction_code" />
        </entity>
        </entity>

    </document>
</dataConfig>
and the schema.xml contains the fields are given below.

Code: Select all

<field name="stock_ST_StockID" type="string" indexed="true" stored="true" required="true"/>
    <field name="stock_ST_StockCode" type="string" indexed="true" stored="true" required="true"/>
    <field name="stock_ST_Name" type="string" indexed="true" stored="true" required="true"/>
    <field name="stock_ST_ItemDetail" type="text" indexed="true" stored="true" required="true"/>

    <field name="auction_iauctionid" type="string" indexed="true" stored="true" required="true"/>
    <field name="auction_rad_number" type="string" indexed="true" stored="true" required="true"/>
    <field name="auction_vsku" type="string" indexed="true" stored="true" required="true"/>
    <field name="auction_auction_code" type="text" indexed="true" stored="true" required="true"/>
But this way the indexes are being created in wrong way as I put the other table data into the first table in data-config.xml.
If I create two entity element like given below then the indexes are not being created.

Code: Select all

<dataConfig>
    <dataSource type="JdbcDataSource" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost/lc" user="root" password=""/>
    <document name="content">
        <entity name="stock" query="select ST_StockID,ST_StockCode,ST_Name,ST_ItemDetail from stock where estatus = 'Active' limit 100">
            <field column="ST_StockID" name="stock_ST_StockID" />
            <field column="ST_StockCode" name="stock_ST_StockCode" />
            <field column="ST_Name" name="stock_ST_Name" />
            <field column="ST_ItemDetail" name="stock_ST_ItemDetail" />

        </entity>
        <entity name="auction" query="select iauctionid,rad_number,vsku,auction_code from auction limit 100">
            <field column="iauctionid" name="auction_iauctionid" />
            <field column="rad_number" name="auction_rad_number" />
            <field column="vsku" name="auction_vsku" />
            <field column="auction_code" name="auction_auction_code" />
        </entity>
    </document>
  </dataConfig>
I did not get your answer, can you pls elaborate a little more. I also have the same requirement. I have two tables stock and auction. Basically I am working on a product site. So I have to create index on both tables. and they are not related at all.

Please help