Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Solr Wiki" for change 
notification.

The following page has been changed by ShalinMangar:
http://wiki.apache.org/solr/DataImportHandler

The comment on the change is:
Removed pk, added clarification on pk

------------------------------------------------------------------------------
   * '''`processor`''' : Required only if the datasource is not RDBMS . (The 
default value is `SqlEntityProcessor`)
   * '''`transformer`'''  : Transformers to be applied on this entity. (See the 
transformer section)
   * '''`dataSource`''' : The name of a datasource as put in the solrconfig.xml 
.(Used if there are multiple datasources) 
-  * '''`pk`''' : The primary key for the entity. Only needed for the root 
entity. This will be the id for the document
+  * '''`pk`''' : The primary key for the entity. It is '''optional''' and only 
needed when using delta-imports. It has no relation to the uniqueKey defined in 
schema.xml but they both can be the same.
   * '''`rootEntity`''' : By default the entities falling under the document 
are root entities. If it is set to false , the entity directly falling under 
that entity will be treated as the root entity (so on and so forth). For every 
row returned by the roor entity a document is created in Solr
  
  For !SqlEntityProcessor the entity attributes are :
@@ -149, +149 @@

  <dataConfig>
  <dataSource driver="org.hsqldb.jdbcDriver" url="jdbc:hsqldb:/temp/example/ex" 
user="sa" />
      <document name="products">
-         <entity name="item" pk="ID" query="select * from item">
+         <entity name="item" query="select * from item">
              <field column="ID" name="id" />
              <field column="NAME" name="name" />
              <field column="MANU" name="manu" />
@@ -159, +159 @@

              <field column="INSTOCK" name="inStock" />
              <field column="INCLUDES" name="includes" />
  
-             <entity name="feature" pk="ITEM_ID" 
-                     query="select description from feature where 
item_id='${item.ID}'">
+             <entity name="feature" query="select description from feature 
where item_id='${item.ID}'">
                  <field name="features" column="description" />
              </entity>
-             <entity name="item_category" pk="ITEM_ID, CATEGORY_ID"
-                     query="select category_id from item_category where 
item_id='${item.ID}'">
+             <entity name="item_category" query="select category_id from 
item_category where item_id='${item.ID}'">
-                 <entity name="category" pk="ID"
-                         query="select description from category where id = 
'${item_category.CATEGORY_ID}'">
+                 <entity name="category" query="select description from 
category where id = '${item_category.CATEGORY_ID}'">
                      <field column="description" name="cat" />
                  </entity>
              </entity>
@@ -177, +174 @@

  
  Here, the root entity is a table called "item" whose primary key is a column 
"id". Data can be read from this table with the query "select * from item". 
Each item can have multiple "features" which are in the table ''feature'' 
inside the column ''description''. Note the query in ''feature'' entity:
  {{{
-    <entity name="feature" pk="ITEM_ID"
-                     query="select description from feature where 
item_id='${item.id}'">
+    <entity name="feature" query="select description from feature where 
item_id='${item.id}'">
-                 <field name="feature" column="description" />
+        <field name="feature" column="description" />
-             </entity> 
+    </entity> 
  }}}
  The ''item_id'' foreign key in feature table is joined together with ''id'' 
primary key in ''item'' to retrieve rows for each row in ''item''. In a similar 
fashion, we join ''item'' and 'category' (which is a many-to-many 
relationship). Notice how we join these two tables using the intermediate table 
''item_category'' again using templated SQL.
  {{{
-  <entity name="item_category" pk="ITEM_ID, CATEGORY_ID"
-                     query="select category_id from item_category where 
item_id='${item.id}'">
+  <entity name="item_category" query="select category_id from item_category 
where item_id='${item.id}'">
-                 <entity name="category" pk="ID"
-                         query="select description from category where id = 
'${item_category.category_id}'">
+                 <entity name="category" query="select description from 
category where id = '${item_category.category_id}'">
                      <field column="description" name="cat" />
                  </entity>
              </entity>
@@ -201, +195 @@

  <dataConfig>
      <dataSource driver="org.hsqldb.jdbcDriver" 
url="jdbc:hsqldb:/temp/example/ex" user="sa" />
      <document>
-         <entity name="item" pk="ID" query="select * from item">               
     
+         <entity name="item" query="select * from item">                    
              <entity name="feature" query="select description as features from 
feature where item_id='${item.ID}'"/>            
              <entity name="item_category" query="select category_id from 
item_category where item_id='${item.ID}'">
                  <entity name="category" query="select description as cat from 
category where id = '${item_category.CATEGORY_ID}'"/>                        

Reply via email to