Hi,

        I am new to Solr, and I am using the DataImportHandler to Query a SQL
Server and populate Solr. I specify the SQL Query in the db-data-config.xml
file. Each SQL Query seems to be associated with an entity. Is it possible
to have a query per field? I think it would be easier to explain this using
an example: 

I have products that are classified in a hierarchy of Categories. A single
product can be in multiple Categories. I want to provide the user the
ability to drill down i.e. first select the top level category Category1,
next select the next level category Category2 etc. Since a single product
can be in multiple Categories, all of these i.e. Category1, Category2,
Category3 etc. are multi-valued.


SQL Database Schema:

Table: Prod_Table
Column 1: SKU  <- ID/Primary Key
Column 2: Title 

Table: Cat_Table
Column 1: SKU <- Foreign Key
Column 2: CategoryLevel
Column 3: CategoryName

Where CategoryLevel is 1, I would like to save the value to Category1 field,
where CategoryLevel is 2, I would like to save this to the Category2 field
etc. My db-data-config.xml looks like:

<dataConfig>
    <dataSource driver="com.microsoft.sqlserver.jdbc.SQLServerDriver"
url="jdbc:sqlserver://localhost…"/>
    <document>
        <entity name="Product" 
                                query="SELECT SKU, Title FROM PROD_TABLE">
            <field column="SKU" name="SKU" />
                        <field column="Title" name="Title" />
                        
                        <entity name=&quot;Categories&quot;  
                    query=&quot;SELECT CategoryName from CAT_TABLE where
SKU='${Product.SKU}' AND CategoryLevel=1&quot;
                &lt;field column=&quot;Category1&quot;
name=&quot;Category1&quot; />
                                 ????Query:  "SELECT CategoryName from 
CAT_TABLE where
SKU='${Product.SKU}' AND CategoryLevel=2"????
                                <field column="Category2" name="Category2" />
                                ???? Query:  "SELECT CategoryName from 
CAT_TABLE where
SKU='${Product.SKU}' AND CategoryLevel=3"????
                                <field column="Category3" name="Category3" />
            </entity>
        </entity>
    </document>
</dataConfig>

How do I populate Category2 and Category3??

Thank you for all your help.
O. O.




--
View this message in context: 
http://lucene.472066.n3.nabble.com/Solr-Data-Config-Queries-per-Field-tp4037092.html
Sent from the Solr - User mailing list archive at Nabble.com.

Reply via email to