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 NoblePaul: http://wiki.apache.org/solr/DataImportHandler ------------------------------------------------------------------------------ == EntityProcessor == Each entity is handled by a default Entity processor called !SqlEntityProcessor. This works well for systems which use RDBMS as a datasource. For other kind of datasources like REST or Non Sql datasources you can choose to implement this interface `org.apache.solr.handler.dataimport.Entityprocessor` {{{ + /** + * An instance of entity processor serves an entity. It is reused for the same + * entity another time. Dees not have to be thread safe. + */ public interface EntityProcessor { + /** This method is called when it starts processing an entity . When it comes back + * to the entity it is called again. So reset anything at that point + * @param context The current context + */ + void init(Context context); + /** - * An instance of this is created everytime. - * This method is called soon after the Object is created. - * - * @param context The current context - */ - void init(Context context); - - /** - * This method helps streaming the data for each row. + * This method helps streaming the data for each row . * The implementation would fetch as many rows as needed and gives one 'row' * at a time. + * Only this method is used during a full import * * @return A 'row' . The 'key' for the map is the column name and the 'value' is the value * of that column. If there are no more rows to be returned, return 'null' */ Map<String, Object> nextRow(); - /**This method is called to get identify the root entities's promary keys whose - * documents have changed - * @return + + /**This is used for delta-import. + * It gives the pks of the changed rows in this entity + * @return the pk vs value of all changed rows */ Map<String, Object> nextModifiedRowKey(); - /**This method is called to get identify the root entities's promary keys whose - * documents have changed - * @return + /** This is used during delta-import. + * It gives the pks of the rows that are deleted from this entity. + * If this entity is the root entity ,solr document is deleted. + * If this is a sub-entity , the solr document is considered as 'changed' and + * will be recreated + * @return the pk vs value of all changed rows */ - Map<String, Object> nextDeletedRowKey(); - - + + /**This is used during delta-import. + * This gives the primary keys and their values of all the rows changed in + * a parent entity due to changes in this entity. + * @return the pk vs value of all changed rows in the parent entity + */ Map<String, Object> nextModifiedParentRowKey(); } - }}} - cofigure it as follows - {{{ - <entity name="foo" implClass="com.FooEntityProcessor" .. - /> - }}} - - == DataSource == - - !DataSource itself is configurable in the system. By default the datasource is `JdbcDataSource`. For other kind of datasources implement the interface `org.apache.solr.handler.dataimport.DataSource` . - - {{{ - public interface DataSource { - - public void init(Context context, Properties initProps); - - /**Get a records for the given query. This is designed to stream records using an iterator - * @param query . The query string . can be an sql for RDBMS . - * @return an iterator of rows where each row is a Map of column/field-name vs the value which can be an object (for single valued field) a or a List<Object> (for multivalued field) - */ - public Iterator<Map<String ,Object>> getRows(String query); - - } }}}
