{"id":386,"date":"2020-01-03T09:54:34","date_gmt":"2020-01-03T09:54:34","guid":{"rendered":"https:\/\/www.aeologic.com\/blog\/?p=386"},"modified":"2020-03-18T08:11:50","modified_gmt":"2020-03-18T08:11:50","slug":"ultimate-solr-guide-7-importing-structured-data-with-data-import-handler","status":"publish","type":"post","link":"https:\/\/www.aeologic.com\/blog\/ultimate-solr-guide-7-importing-structured-data-with-data-import-handler\/","title":{"rendered":"Importing data with Data Import Handler &#8211; Ultimate Solr Guide"},"content":{"rendered":"<h3>Introduction<\/h3>\n<p>Hello everyone! We are back with another post. Today we will discuss in detail another important aspect used in many enterprise-grade applications. All organizations big and small in evidently store data some form of structured data store. Data import handler provides a mechanism for importing content of that datastore and indexing it. In addition to it, there can be HTTP\/RSS based data store along with ATOM feeds, email repositories, structures XML, so on and so forth.<\/p>\n<h3>How DIH is configured?<\/h3>\n<p>DIH handler is ideally configured in solrconfig.xml. The handler configuration itself is easy and demands less work. However, when implementing with varied types of data stores, the intrinsic complexity of it becomes pretty evident. For instance, Data Import Handler can be configured as follows :<\/p>\n<p><img fetchpriority=\"high\" decoding=\"async\" class=\"alignnone size-full wp-image-387\" src=\"https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/01\/carbon-6.png\" alt=\"\" width=\"1918\" height=\"554\" srcset=\"https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/01\/carbon-6.png 889w, https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/01\/carbon-6-720x208.png 720w, https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/01\/carbon-6-260x75.png 260w, https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/01\/carbon-6-277x80.png 277w, https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/01\/carbon-6-250x72.png 250w, https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/01\/carbon-6-300x87.png 300w, https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/01\/carbon-6-768x222.png 768w\" sizes=\"(max-width: 1918px) 100vw, 1918px\" \/><\/p>\n<p>The config file here defines the information like, how to fetch data, what to fetch, the document structure conceived etc. The below example shows how to extract fields from four tables defining a simple product database. More information about the parameters and options shown here will be described in the sections following :<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-388\" src=\"https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/01\/carbon-7.png\" alt=\"\" width=\"2048\" height=\"1598\" srcset=\"https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/01\/carbon-7.png 384w, https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/01\/carbon-7-260x203.png 260w, https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/01\/carbon-7-102x80.png 102w, https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/01\/carbon-7-243x190.png 243w, https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/01\/carbon-7-300x234.png 300w\" sizes=\"(max-width: 2048px) 100vw, 2048px\" \/><\/p>\n<ul>\n<li>The first element is the <code>dataSource<\/code>, in this case an HSQLDB database. The path to the JDBC driver and the JDBC URL and login credentials are all specified here. Other permissible attributes include whether or not to autocommit to Solr, the batchsize used in the JDBC connection, and a\u00a0<code>readOnly<\/code> flag. The password attribute is optional if there is no password set for the DB.<\/li>\n<li>Alternately the password can be encrypted as follows. This is the value obtained as a result of the command\u00a0<code>openssl enc -aes-128-cbc -a -salt -in pwd.txt password=\"U2FsdGVkX18QMjY0yfCqlfBMvAB4d3XkwY96L7gfO2o=\"<\/code>. When the password is encrypted, you must provide an extra attribute\u00a0<code>encryptKeyFile=\"\/location\/of\/encryptionkey\"<\/code>. This file should a text file with a single line containing the encrypt\/decrypt password.<\/li>\n<li>A\u00a0<code>document<\/code>\u00a0element follows, containing multiple\u00a0<code>entity<\/code>\u00a0elements. Note that\u00a0<code>entity<\/code>\u00a0elements can be nested, and this allows the entity relationships in the sample database to be mirrored here, so that we can generate a denormalized Solr record which may include multiple features for one item, for instance.<\/li>\n<li>The possible attributes for the\u00a0<code>entity<\/code>\u00a0element are described in later sections. Entity elements may contain one or more\u00a0<code>field<\/code>\u00a0elements, which map the data source field names to Solr fields, and optionally specify per-field transformations. This entity is the\u00a0<code>root<\/code>\u00a0entity.<\/li>\n<li>This entity is nested and reflects the one-to-many relationship between an item and its multiple features. Note the use of variables;\u00a0<code>${item.ID}<\/code>\u00a0is the value of the column &#8216;ID&#8217; for the current item (<code>item<\/code> referring to the entity name).<\/li>\n<\/ul>\n<div class=\"paragraph\">\n<p>Datasources can still be specified in\u00a0<code>solrconfig.xml<\/code>. These must be specified in the defaults section of the handler in\u00a0<code>solrconfig.xml<\/code>. However, these are not parsed until the main configuration is loaded.<\/p>\n<\/div>\n<div class=\"paragraph\">\n<p>The entire configuration itself can be passed as a request parameter using the\u00a0<code>dataConfig<\/code>\u00a0parameter rather than using a file. When configuration errors are encountered, the error message is returned in XML format.<\/p>\n<\/div>\n<div class=\"paragraph\">\n<p>A\u00a0<code>reload-config<\/code>\u00a0command is also supported, which is useful for validating a new configuration file, or if you want to specify a file, load it, and not have it reloaded again on import. If there is an\u00a0<code>xml<\/code>\u00a0mistake in the configuration a user-friendly message is returned in\u00a0<code>xml<\/code>\u00a0format. You can then fix the problem and do a\u00a0<code>reload-config.<\/code><\/p>\n<\/div>\n<h3>Important Commands<\/h3>\n<div class=\"dlist\">\n<dl>\n<dt class=\"hdlist1\"><strong>abort<\/strong><\/dt>\n<dd>Aborts an ongoing operation. For example:\u00a0<code>http:\/\/localhost:8983\/solr\/dih\/dataimport?command=abort<\/code>.<\/dd>\n<dt class=\"hdlist1\"><strong>delta-import<\/strong><\/dt>\n<dd>For incremental imports and change detection. Only the\u00a0<a href=\"https:\/\/lucene.apache.org\/solr\/guide\/6_6\/uploading-structured-data-store-data-with-the-data-import-handler.html#the-sql-entity-processor\">SqlEntityProcessor<\/a>\u00a0supports delta imports.<\/p>\n<div class=\"paragraph\">\n<p>For example:\u00a0<code>http:\/\/localhost:8983\/solr\/dih\/dataimport?command=delta-import<\/code>.<\/p>\n<\/div>\n<div class=\"paragraph\">\n<p>This command supports the same\u00a0<code>clean<\/code>,\u00a0<code>commit<\/code>,\u00a0<code>optimize<\/code>\u00a0and\u00a0<code>debug<\/code>\u00a0parameters as\u00a0<code>full-import<\/code>\u00a0command described below.<\/p>\n<\/div>\n<\/dd>\n<dt class=\"hdlist1\"><strong>full-import<\/strong><\/dt>\n<dd>A Full Import operation can be started with a URL such as\u00a0<code>http:\/\/localhost:8983\/solr\/dih\/dataimport?command=full-import<\/code>. The command returns immediately.<\/p>\n<div class=\"paragraph\">\n<p>The operation will be started in a new thread and the\u00a0<em>status<\/em>\u00a0attribute in the response should be shown as\u00a0<em>busy<\/em>. The operation may take some time depending on the size of dataset. Queries to Solr are not blocked during full-imports.<\/p>\n<\/div>\n<div class=\"paragraph\">\n<p>When a\u00a0<code>full-import<\/code>\u00a0command is executed, it stores the start time of the operation in a file located at\u00a0<code>conf\/dataimport.properties<\/code>. This stored timestamp is used when a\u00a0<code>delta-import<\/code>\u00a0operation is executed.<\/p>\n<\/div>\n<div class=\"paragraph\">\n<p>Commands available to\u00a0<code>full-import<\/code>\u00a0are:<\/p>\n<\/div>\n<div class=\"dlist\">\n<dl>\n<dt class=\"hdlist1\"><strong>clean<\/strong><\/dt>\n<dd>Default is true. Tells whether to clean up the index before the indexing is started.<\/dd>\n<dt class=\"hdlist1\"><strong>commit<\/strong><\/dt>\n<dd>Default is true. Tells whether to commit after the operation.<\/dd>\n<dt class=\"hdlist1\"><strong>debug<\/strong><\/dt>\n<dd>Default is false. Runs the command in debug mode and is used by the interactive development mode.<\/p>\n<div class=\"paragraph\">\n<p>Note that in debug mode, documents are never committed automatically. If you want to run debug mode and commit the results too, add\u00a0<code>commit=true<\/code>\u00a0as a request parameter.<\/p>\n<\/div>\n<\/dd>\n<dt class=\"hdlist1\"><strong>entity<\/strong><\/dt>\n<dd>The name of an entity directly under the\u00a0<code>&lt;document&gt;<\/code>\u00a0tag in the configuration file. Use this to execute one or more entities selectively.<\/p>\n<div class=\"paragraph\">\n<p>Multiple &#8220;entity&#8221; parameters can be passed on to run multiple entities at once. If nothing is passed, all entities are executed.<\/p>\n<\/div>\n<\/dd>\n<dt class=\"hdlist1\"><strong>optimize<\/strong><\/dt>\n<dd>Default is true. Tells Solr whether to optimize after the operation.<\/dd>\n<dt class=\"hdlist1\"><strong>synchronous<\/strong><\/dt>\n<dd>Blocks request until import is completed. Default is false.<\/dd>\n<\/dl>\n<\/div>\n<\/dd>\n<dt class=\"hdlist1\"><strong>reload-config<\/strong><\/dt>\n<dd>If the configuration file has been changed and you wish to reload it without restarting Solr, run the command\u00a0<code>http:\/\/localhost:8983\/solr\/dih\/dataimport?command=reload-config<\/code><\/dd>\n<dt class=\"hdlist1\"><strong>status<\/strong><\/dt>\n<dd>This command returns statistics on the number of documents created, deleted, queries run, rows fetched, status, and so on. For example:\u00a0<code>http:\/\/localhost:8983\/solr\/dih\/dataimport?command=status<\/code>.<\/dd>\n<dt class=\"hdlist1\"><strong>show<\/strong>&#8211;<strong>config<\/strong><\/dt>\n<dd>This command responds with configuration:\u00a0<code>http:\/\/localhost:8983\/solr\/dih\/dataimport?command=show-config<\/code>.<\/dd>\n<\/dl>\n<h3><strong>Some Important Processors<\/strong><\/h3>\n<\/div>\n<div class=\"paragraph\">\n<p>Entity processors extract data, transform it, and add it to a Solr index. Examples of entities include views or tables in a data store.<\/p>\n<\/div>\n<div class=\"paragraph\">\n<p>Each processor has its own set of attributes, described in its own section below. In addition, there are several attributes common to all entities which may be specified:<\/p>\n<\/div>\n<div class=\"dlist\">\n<dl>\n<dt class=\"hdlist1\"><strong>dataSource<\/strong><\/dt>\n<dd>The name of a data source. If there are multiple data sources defined, use this attribute with the name of the data source for this entity.<\/dd>\n<dt class=\"hdlist1\"><strong>name<\/strong><\/dt>\n<dd>Required. The unique name used to identify an entity.<\/dd>\n<dt class=\"hdlist1\"><strong>pk<\/strong><\/dt>\n<dd>The primary key for the entity. It is optional, and required only when using delta-imports. It has no relation to the uniqueKey defined in\u00a0<code>schema.xml<\/code>\u00a0but they can both be the same.<\/p>\n<div class=\"paragraph\">\n<p>This attribute is mandatory if you do delta-imports and then refer to the column name in\u00a0<code>${dataimporter.delta.&lt;column-name&gt;}<\/code>\u00a0which is used as the primary key.<\/p>\n<\/div>\n<\/dd>\n<dt class=\"hdlist1\"><strong>processor<\/strong><\/dt>\n<dd>Default is\u00a0<a href=\"https:\/\/lucene.apache.org\/solr\/guide\/6_6\/uploading-structured-data-store-data-with-the-data-import-handler.html#the-sql-entity-processor\">SqlEntityProcessor<\/a>. Required only if the datasource is not RDBMS.<\/dd>\n<dt class=\"hdlist1\"><strong>onError<\/strong><\/dt>\n<dd>Defines what to do if an error is encountered.<\/p>\n<div class=\"paragraph\">\n<p>Permissible values are:<\/p>\n<\/div>\n<div class=\"dlist\">\n<dl>\n<dt class=\"hdlist1\">abort<\/dt>\n<dd>Stops the import.<\/dd>\n<dt class=\"hdlist1\">skip<\/dt>\n<dd>Skips the current document.<\/dd>\n<dt class=\"hdlist1\">continue<\/dt>\n<dd>Ignores the error and processing continues.<\/dd>\n<\/dl>\n<\/div>\n<\/dd>\n<dt class=\"hdlist1\"><strong>preImportDeleteQuery<\/strong><\/dt>\n<dd>Before a\u00a0<code>full-import<\/code>\u00a0command, use this query this to cleanup the index instead of using\u00a0<code>*:*<\/code>. This is honored only on an entity that is an immediate sub-child of\u00a0<code>&lt;document&gt;<\/code>.<\/dd>\n<dt class=\"hdlist1\"><strong>postImportDeleteQuery<\/strong><\/dt>\n<dd>Similar to\u00a0<code>preImportDeleteQuery<\/code>, but it executes after the import has completed.<\/dd>\n<dt class=\"hdlist1\"><strong>rootEntity<\/strong><\/dt>\n<dd>By default the entities immediately under\u00a0<code>&lt;document&gt;<\/code>\u00a0are root entities. If this attribute is set to false, the entity directly falling under that entity will be treated as the root entity (and so on). For every row returned by the root entity, a document is created in Solr.<\/dd>\n<dt class=\"hdlist1\"><strong>transformer<\/strong><\/dt>\n<dd>Optional. One or more transformers to be applied on this entity.<\/dd>\n<dt class=\"hdlist1\"><strong>cacheImpl<\/strong><\/dt>\n<dd>Optional. A class (which must implement\u00a0<code>DIHCache<\/code>) to use for caching this entity when doing lookups from an entity which wraps it. Provided implementation is\u00a0<code>SortedMapBackedCache<\/code>.<\/dd>\n<dt class=\"hdlist1\"><strong>cacheKey<\/strong><\/dt>\n<dd>The name of a property of this entity to use as a cache key if\u00a0<code>cacheImpl<\/code>\u00a0is specified.<\/dd>\n<dt class=\"hdlist1\"><strong>cacheLookup<\/strong><\/dt>\n<dd>An entity + property name that will be used to lookup cached instances of this entity if\u00a0<code>cacheImpl<\/code>\u00a0is specified.<\/dd>\n<dt class=\"hdlist1\"><strong>where<\/strong><\/dt>\n<dd>An alternative way to specify\u00a0<code>cacheKey<\/code>\u00a0and\u00a0<code>cacheLookup<\/code>\u00a0concatenated with &#8216;=&#8217;.<\/p>\n<div class=\"paragraph\">\n<p>For example,\u00a0<code>where=\"CODE=People.COUNTRY_CODE\"<\/code>\u00a0is equivalent to\u00a0<code>cacheKey=\"CODE\" cacheLookup=\"People.COUNTRY_CODE\"<\/code><\/p>\n<\/div>\n<\/dd>\n<dt class=\"hdlist1\"><strong>child=&#8221;true&#8221;<\/strong><\/dt>\n<dd>Enables indexing document blocks aka\u00a0<a href=\"https:\/\/lucene.apache.org\/solr\/guide\/6_6\/uploading-data-with-index-handlers.html#uploading-data-with-index-handlers\">Nested Child Documents<\/a>\u00a0for searching with\u00a0<a href=\"https:\/\/lucene.apache.org\/solr\/guide\/6_6\/other-parsers.html#other-parsers\">Block Join Query Parsers<\/a>. It can be only specified on the\u00a0<code>&lt;entity&gt;<\/code>\u00a0element under another root entity. It switches from default behavior (merging field values) to nesting documents as children documents.<\/p>\n<div class=\"paragraph\">\n<p>Note: parent\u00a0<code>&lt;entity&gt;<\/code>\u00a0should add a field which is used as a parent filter in query time.<\/p>\n<\/div>\n<\/dd>\n<dt class=\"hdlist1\"><strong>join=&#8221;zipper&#8221;<\/strong><\/dt>\n<dd>Enables merge join, aka &#8220;zipper&#8221; algorithm, for joining parent and child entities without cache. It should be specified at child (nested)\u00a0<code>&lt;entity&gt;<\/code>. It implies that parent and child queries return results ordered by keys, otherwise it throws an exception. Keys should be specified either with\u00a0<code>where<\/code>\u00a0attribute or with\u00a0<code>cacheKey<\/code>\u00a0and\u00a0<code>cacheLookup<\/code>.<\/dd>\n<\/dl>\n<\/div>\n<div class=\"sect2\">\n<div class=\"sect2\">\n<h3 id=\"the-sql-entity-processor\">The SQL Entity Processor<\/h3>\n<div class=\"paragraph\">\n<p>The SqlEntityProcessor is the default processor. The associated\u00a0<a href=\"https:\/\/lucene.apache.org\/solr\/guide\/6_6\/uploading-structured-data-store-data-with-the-data-import-handler.html#jdbcdatasource\">JdbcDataSource<\/a>\u00a0should be a JDBC URL.<\/p>\n<\/div>\n<div class=\"paragraph\">\n<p>The entity attributes specific to this processor are shown in the table below. These are in addition to the attributes common to all entity processors described above.<\/p>\n<\/div>\n<div class=\"dlist\">\n<dl>\n<dt class=\"hdlist1\"><strong>query<\/strong><\/dt>\n<dd>Required. The SQL query used to select rows.<\/dd>\n<dt class=\"hdlist1\"><strong>deltaQuery<\/strong><\/dt>\n<dd>SQL query used if the operation is delta-import. This query selects the primary keys of the rows which will be parts of the delta-update. The pks will be available to the deltaImportQuery through the variable\u00a0<code>${dataimporter.delta.&lt;column-name&gt;}<\/code>.<\/dd>\n<dt class=\"hdlist1\"><strong>parentDeltaQuery<\/strong><\/dt>\n<dd>SQL query used if the operation is\u00a0<code>delta-import<\/code>.<\/dd>\n<dt class=\"hdlist1\"><strong>deletedPkQuery<\/strong><\/dt>\n<dd>SQL query used if the operation is\u00a0<code>delta-import<\/code>.<\/dd>\n<dt class=\"hdlist1\"><strong>deltaImportQuery<\/strong><\/dt>\n<dd>SQL query used if the operation is\u00a0<code>delta-import<\/code>. If this is not present, DIH tries to construct the import query by (after identifying the delta) modifying the &#8216;query&#8217; (this is error prone).<\/p>\n<div class=\"paragraph\">\n<p>There is a namespace\u00a0<code>${dataimporter.delta.&lt;column-name&gt;}<\/code>\u00a0which can be used in this query. For example,\u00a0<code>select * from tbl where id=${dataimporter.delta.id}<\/code>.<\/p>\n<\/div>\n<\/dd>\n<\/dl>\n<\/div>\n<\/div>\n<div class=\"sect2\">\n<h3 id=\"the-xpathentityprocessor\">The XPathEntityProcessor<\/h3>\n<div class=\"paragraph\">\n<p>This processor is used when indexing XML formatted data. The data source is typically\u00a0<a href=\"https:\/\/lucene.apache.org\/solr\/guide\/6_6\/uploading-structured-data-store-data-with-the-data-import-handler.html#urldatasource\">URLDataSource<\/a>\u00a0or\u00a0<a href=\"https:\/\/lucene.apache.org\/solr\/guide\/6_6\/uploading-structured-data-store-data-with-the-data-import-handler.html#filedatasource\">FileDataSource<\/a>. XPath can also be used with the\u00a0<a href=\"https:\/\/lucene.apache.org\/solr\/guide\/6_6\/uploading-structured-data-store-data-with-the-data-import-handler.html#the-filelistentityprocessor\">FileListEntityProcessor<\/a>\u00a0described below, to generate a document from each file.<\/p>\n<\/div>\n<div class=\"paragraph\">\n<p>The entity attributes unique to this processor are shown below. These are in addition to the attributes common to all entity processors described above.<\/p>\n<\/div>\n<div class=\"dlist\">\n<dl>\n<dt class=\"hdlist1\"><strong>Processor<\/strong><\/dt>\n<dd>Required. Must be set to\u00a0<code>XpathEntityProcessor<\/code>.<\/dd>\n<dt class=\"hdlist1\"><strong>url<\/strong><\/dt>\n<dd>Required. The HTTP URL or file location.<\/dd>\n<dt class=\"hdlist1\"><strong>stream<\/strong><\/dt>\n<dd>Optional: Set to true for a large file or download.<\/dd>\n<dt class=\"hdlist1\"><strong>forEach<\/strong><\/dt>\n<dd>Required unless you define\u00a0<code>useSolrAddSchema<\/code>. The XPath expression which demarcates each record. This will be used to set up the processing loop.<\/dd>\n<dt class=\"hdlist1\"><strong>xsl<\/strong><\/dt>\n<dd>Optional: Its value (a URL or filesystem path) is the name of a resource used as a preprocessor for applying the XSL transformation.<\/dd>\n<dt class=\"hdlist1\"><strong>useSolrAddSchema<\/strong><\/dt>\n<dd>Set this to true if the content is in the form of the standard Solr update XML schema.<\/dd>\n<\/dl>\n<\/div>\n<div class=\"paragraph\">\n<p><strong>Each<\/strong>\u00a0<code>&lt;field&gt;<\/code>\u00a0element in the entity can have the following attributes as well as the default ones.<\/p>\n<\/div>\n<div class=\"dlist\">\n<dl>\n<dt class=\"hdlist1\"><strong>xpath<\/strong><\/dt>\n<dd>Required. The XPath expression which will extract the content from the record for this field. Only a subset of XPath syntax is supported.<\/dd>\n<dt class=\"hdlist1\"><strong>commonField<\/strong><\/dt>\n<dd>Optional. If true, then when this field is encountered in a record it will be copied to future records when creating a Solr document.<\/dd>\n<dt class=\"hdlist1\"><strong>flatten<\/strong><\/dt>\n<dd>Optional. If set to true, then any children text nodes are collected to form the value of a field.<\/dd>\n<\/dl>\n<h3 id=\"the-tikaentityprocessor\">The TikaEntityProcessor<\/h3>\n<div class=\"paragraph\">\n<p>The TikaEntityProcessor uses Apache Tika to process incoming documents. This is similar to\u00a0<a href=\"https:\/\/lucene.apache.org\/solr\/guide\/6_6\/uploading-data-with-solr-cell-using-apache-tika.html#uploading-data-with-solr-cell-using-apache-tika\">Uploading Data with Solr Cell using Apache Tika<\/a>, but using DataImportHandler options instead.<\/p>\n<\/div>\n<div class=\"paragraph\">\n<p>The parameters for this processor are described in the table below. These are in addition to the attributes common to all entity processors described above.<\/p>\n<\/div>\n<div class=\"dlist\">\n<dl>\n<dt class=\"hdlist1\"><strong>dataSource<\/strong><\/dt>\n<dd>This parameter defines the data source and an optional name which can be referred to in later parts of the configuration if needed. This is the same\u00a0<code>dataSource<\/code>\u00a0explained in the description of general entity processor attributes above.<\/p>\n<div class=\"paragraph\">\n<p>The available data source types for this processor are:<\/p>\n<\/div>\n<div class=\"ulist\">\n<ul>\n<li>BinURLDataSource: used for HTTP resources, but can also be used for files.<\/li>\n<li>BinContentStreamDataSource: used for uploading content as a stream.<\/li>\n<li>BinFileDataSource: used for content on the local filesystem.<\/li>\n<\/ul>\n<\/div>\n<\/dd>\n<dt class=\"hdlist1\"><strong>url<\/strong><\/dt>\n<dd>Required. The path to the source file(s), as a file path or a traditional internet URL.<\/dd>\n<dt class=\"hdlist1\"><strong>htmlMapper<\/strong><\/dt>\n<dd>Optional. Allows control of how Tika parses HTML. If this parameter is defined, it must be either\u00a0<strong>default<\/strong>\u00a0or\u00a0<strong>identity<\/strong>; if it is absent, &#8220;default&#8221; is assumed.<\/p>\n<div class=\"paragraph\">\n<p>The &#8220;default&#8221; mapper strips much of the HTML from documents while the &#8220;identity&#8221; mapper passes all HTML as-is with no modifications.<\/p>\n<\/div>\n<\/dd>\n<dt class=\"hdlist1\"><strong>format<\/strong><\/dt>\n<dd>The output format. The options are\u00a0<strong>text<\/strong>,\u00a0<strong>xml<\/strong>,\u00a0<strong>html<\/strong>\u00a0or\u00a0<strong>none<\/strong>. The default is &#8220;text&#8221; if not defined. The format &#8220;none&#8221; can be used if metadata only should be indexed and not the body of the documents.<\/dd>\n<dt class=\"hdlist1\"><strong>parser<\/strong><\/dt>\n<dd>Optional. The default parser is\u00a0<code>org.apache.tika.parser.AutoDetectParser<\/code>. If a custom or other parser should be used, it should be entered as a fully-qualified name of the class and path.<\/dd>\n<dt class=\"hdlist1\"><strong>fields<\/strong><\/dt>\n<dd>The list of fields from the input documents and how they should be mapped to Solr fields. If the attribute\u00a0<code>meta<\/code>\u00a0is defined as &#8220;true&#8221;, the field will be obtained from the metadata of the document and not parsed from the body of the main text.<\/dd>\n<dt class=\"hdlist1\"><strong>extractEmbedded<\/strong><\/dt>\n<dd>Instructs the TikaEntityProcessor to extract embedded documents or attachments when\u00a0<strong>true<\/strong>. If false, embedded documents and attachments will be ignored.<\/dd>\n<dt class=\"hdlist1\"><strong>onError<\/strong><\/dt>\n<dd>By default, the TikaEntityProcessor will stop processing documents if it finds one that generates an error. If you define\u00a0<code>onError<\/code>\u00a0to &#8220;skip&#8221;, the TikaEntityProcessor will instead skip documents that fail processing and log a message that the document was skipped.<\/p>\n<p><strong>For Example<\/strong> :<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-392\" src=\"https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/01\/carbon-9.png\" alt=\"\" width=\"1614\" height=\"986\" srcset=\"https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/01\/carbon-9.png 491w, https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/01\/carbon-9-260x159.png 260w, https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/01\/carbon-9-131x80.png 131w, https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/01\/carbon-9-250x153.png 250w, https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/01\/carbon-9-300x183.png 300w\" sizes=\"(max-width: 1614px) 100vw, 1614px\" \/><\/dd>\n<\/dl>\n<p>So, this is it about Data import handler solr. We will be back with another post on solr very soon.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Introduction Hello everyone! We are back with another post. Today we will discuss in detail another important aspect used in many enterprise-grade applications. All organizations big and small in evidently store data some form of structured data store. Data import handler provides a mechanism for importing content of that datastore and indexing it. In addition to it, there can be HTTP\/RSS based data store along with ATOM feeds, email repositories, structures XML, so on and so forth. How DIH is configured? DIH handler is ideally configured in solrconfig.xml. The handler configuration itself is easy and demands less work. However, when implementing with varied types of data stores, the intrinsic complexity of it becomes pretty evident. For instance, Data Import Handler can be configured as follows : The config file here defines the information like, how to fetch data, what to fetch, the document structure conceived etc. The below example shows how to extract fields from four tables defining a simple product database. More information about the parameters and options shown here will be described in the sections following : The first element is the dataSource, in this case an HSQLDB database. The path to the JDBC driver and the JDBC URL and login credentials are all specified here. Other permissible attributes include whether or not to autocommit to Solr, the batchsize used in the JDBC connection, and a\u00a0readOnly flag. The password attribute is optional if there is no password set for the DB. Alternately the password can be encrypted as follows. This is the value obtained as a result of the command\u00a0openssl enc -aes-128-cbc -a -salt -in pwd.txt password=&#8221;U2FsdGVkX18QMjY0yfCqlfBMvAB4d3XkwY96L7gfO2o=&#8221;. When the password is encrypted, you must provide an extra attribute\u00a0encryptKeyFile=&#8221;\/location\/of\/encryptionkey&#8221;. This file should a text file with a single line containing the encrypt\/decrypt password. A\u00a0document\u00a0element follows, containing multiple\u00a0entity\u00a0elements. Note that\u00a0entity\u00a0elements can be nested, and this allows the entity relationships in the sample database to be mirrored here, so that we can generate a denormalized Solr record which may include multiple features for one item, for instance. The possible attributes for the\u00a0entity\u00a0element are described in later sections. Entity elements may contain one or more\u00a0field\u00a0elements, which map the data source field names to Solr fields, and optionally specify per-field transformations. This entity is the\u00a0root\u00a0entity. This entity is nested and reflects the one-to-many relationship between an item and its multiple features. Note the use of variables;\u00a0${item.ID}\u00a0is the value of the column &#8216;ID&#8217; for the current item (item referring to the entity name). Datasources can still be specified in\u00a0solrconfig.xml. These must be specified in the defaults section of the handler in\u00a0solrconfig.xml. However, these are not parsed until the main configuration is loaded. The entire configuration itself can be passed as a request parameter using the\u00a0dataConfig\u00a0parameter rather than using a file. When configuration errors are encountered, the error message is returned in XML format. A\u00a0reload-config\u00a0command is also supported, which is useful for validating a new configuration file, or if you want to specify a file, load it, and not have it reloaded again on import. If there is an\u00a0xml\u00a0mistake in the configuration a user-friendly message is returned in\u00a0xml\u00a0format. You can then fix the problem and do a\u00a0reload-config. Important Commands abort Aborts an ongoing operation. For example:\u00a0http:\/\/localhost:8983\/solr\/dih\/dataimport?command=abort. delta-import For incremental imports and change detection. Only the\u00a0SqlEntityProcessor\u00a0supports delta imports. For example:\u00a0http:\/\/localhost:8983\/solr\/dih\/dataimport?command=delta-import. This command supports the same\u00a0clean,\u00a0commit,\u00a0optimize\u00a0and\u00a0debug\u00a0parameters as\u00a0full-import\u00a0command described below. full-import A Full Import operation can be started with a URL such as\u00a0http:\/\/localhost:8983\/solr\/dih\/dataimport?command=full-import. The command returns immediately. The operation will be started in a new thread and the\u00a0status\u00a0attribute in the response should be shown as\u00a0busy. The operation may take some time depending on the size of dataset. Queries to Solr are not blocked during full-imports. When a\u00a0full-import\u00a0command is executed, it stores the start time of the operation in a file located at\u00a0conf\/dataimport.properties. This stored timestamp is used when a\u00a0delta-import\u00a0operation is executed. Commands available to\u00a0full-import\u00a0are: clean Default is true. Tells whether to clean up the index before the indexing is started. commit Default is true. Tells whether to commit after the operation. debug Default is false. Runs the command in debug mode and is used by the interactive development mode. Note that in debug mode, documents are never committed automatically. If you want to run debug mode and commit the results too, add\u00a0commit=true\u00a0as a request parameter. entity The name of an entity directly under the\u00a0&lt;document&gt;\u00a0tag in the configuration file. Use this to execute one or more entities selectively. Multiple &#8220;entity&#8221; parameters can be passed on to run multiple entities at once. If nothing is passed, all entities are executed. optimize Default is true. Tells Solr whether to optimize after the operation. synchronous Blocks request until import is completed. Default is false. reload-config If the configuration file has been changed and you wish to reload it without restarting Solr, run the command\u00a0http:\/\/localhost:8983\/solr\/dih\/dataimport?command=reload-config status This command returns statistics on the number of documents created, deleted, queries run, rows fetched, status, and so on. For example:\u00a0http:\/\/localhost:8983\/solr\/dih\/dataimport?command=status. show&#8211;config This command responds with configuration:\u00a0http:\/\/localhost:8983\/solr\/dih\/dataimport?command=show-config. Some Important Processors Entity processors extract data, transform it, and add it to a Solr index. Examples of entities include views or tables in a data store. Each processor has its own set of attributes, described in its own section below. In addition, there are several attributes common to all entities which may be specified: dataSource The name of a data source. If there are multiple data sources defined, use this attribute with the name of the data source for this entity. name Required. The unique name used to identify an entity. pk The primary key for the entity. It is optional, and required only when using delta-imports. It has no relation to the uniqueKey defined in\u00a0schema.xml\u00a0but they can both be the same. This attribute is mandatory if you do delta-imports and then refer to the column name in\u00a0${dataimporter.delta.&lt;column-name&gt;}\u00a0which is used as the primary key. processor Default is\u00a0SqlEntityProcessor. Required only if the datasource is not RDBMS. onError Defines what to do if an error is encountered. Permissible values are: abort Stops the import. skip Skips the current document. continue [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":395,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[41],"tags":[14,2,57,58,59,24,60],"class_list":["post-386","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-solr","tag-apache-solr","tag-application-development","tag-data-import-handler","tag-dih","tag-handler","tag-solr-core","tag-solr-handler"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v23.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Importing data with Data Import Handler - Ultimate Solr Guide - Aeologic Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.aeologic.com\/blog\/ultimate-solr-guide-7-importing-structured-data-with-data-import-handler\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Importing data with Data Import Handler - Ultimate Solr Guide - Aeologic Blog\" \/>\n<meta property=\"og:description\" content=\"Introduction Hello everyone! We are back with another post. Today we will discuss in detail another important aspect used in many enterprise-grade applications. All organizations big and small in evidently store data some form of structured data store. Data import handler provides a mechanism for importing content of that datastore and indexing it. In addition to it, there can be HTTP\/RSS based data store along with ATOM feeds, email repositories, structures XML, so on and so forth. How DIH is configured? DIH handler is ideally configured in solrconfig.xml. The handler configuration itself is easy and demands less work. However, when implementing with varied types of data stores, the intrinsic complexity of it becomes pretty evident. For instance, Data Import Handler can be configured as follows : The config file here defines the information like, how to fetch data, what to fetch, the document structure conceived etc. The below example shows how to extract fields from four tables defining a simple product database. More information about the parameters and options shown here will be described in the sections following : The first element is the dataSource, in this case an HSQLDB database. The path to the JDBC driver and the JDBC URL and login credentials are all specified here. Other permissible attributes include whether or not to autocommit to Solr, the batchsize used in the JDBC connection, and a\u00a0readOnly flag. The password attribute is optional if there is no password set for the DB. Alternately the password can be encrypted as follows. This is the value obtained as a result of the command\u00a0openssl enc -aes-128-cbc -a -salt -in pwd.txt password=&quot;U2FsdGVkX18QMjY0yfCqlfBMvAB4d3XkwY96L7gfO2o=&quot;. When the password is encrypted, you must provide an extra attribute\u00a0encryptKeyFile=&quot;\/location\/of\/encryptionkey&quot;. This file should a text file with a single line containing the encrypt\/decrypt password. A\u00a0document\u00a0element follows, containing multiple\u00a0entity\u00a0elements. Note that\u00a0entity\u00a0elements can be nested, and this allows the entity relationships in the sample database to be mirrored here, so that we can generate a denormalized Solr record which may include multiple features for one item, for instance. The possible attributes for the\u00a0entity\u00a0element are described in later sections. Entity elements may contain one or more\u00a0field\u00a0elements, which map the data source field names to Solr fields, and optionally specify per-field transformations. This entity is the\u00a0root\u00a0entity. This entity is nested and reflects the one-to-many relationship between an item and its multiple features. Note the use of variables;\u00a0${item.ID}\u00a0is the value of the column &#8216;ID&#8217; for the current item (item referring to the entity name). Datasources can still be specified in\u00a0solrconfig.xml. These must be specified in the defaults section of the handler in\u00a0solrconfig.xml. However, these are not parsed until the main configuration is loaded. The entire configuration itself can be passed as a request parameter using the\u00a0dataConfig\u00a0parameter rather than using a file. When configuration errors are encountered, the error message is returned in XML format. A\u00a0reload-config\u00a0command is also supported, which is useful for validating a new configuration file, or if you want to specify a file, load it, and not have it reloaded again on import. If there is an\u00a0xml\u00a0mistake in the configuration a user-friendly message is returned in\u00a0xml\u00a0format. You can then fix the problem and do a\u00a0reload-config. Important Commands abort Aborts an ongoing operation. For example:\u00a0http:\/\/localhost:8983\/solr\/dih\/dataimport?command=abort. delta-import For incremental imports and change detection. Only the\u00a0SqlEntityProcessor\u00a0supports delta imports. For example:\u00a0http:\/\/localhost:8983\/solr\/dih\/dataimport?command=delta-import. This command supports the same\u00a0clean,\u00a0commit,\u00a0optimize\u00a0and\u00a0debug\u00a0parameters as\u00a0full-import\u00a0command described below. full-import A Full Import operation can be started with a URL such as\u00a0http:\/\/localhost:8983\/solr\/dih\/dataimport?command=full-import. The command returns immediately. The operation will be started in a new thread and the\u00a0status\u00a0attribute in the response should be shown as\u00a0busy. The operation may take some time depending on the size of dataset. Queries to Solr are not blocked during full-imports. When a\u00a0full-import\u00a0command is executed, it stores the start time of the operation in a file located at\u00a0conf\/dataimport.properties. This stored timestamp is used when a\u00a0delta-import\u00a0operation is executed. Commands available to\u00a0full-import\u00a0are: clean Default is true. Tells whether to clean up the index before the indexing is started. commit Default is true. Tells whether to commit after the operation. debug Default is false. Runs the command in debug mode and is used by the interactive development mode. Note that in debug mode, documents are never committed automatically. If you want to run debug mode and commit the results too, add\u00a0commit=true\u00a0as a request parameter. entity The name of an entity directly under the\u00a0&lt;document&gt;\u00a0tag in the configuration file. Use this to execute one or more entities selectively. Multiple &#8220;entity&#8221; parameters can be passed on to run multiple entities at once. If nothing is passed, all entities are executed. optimize Default is true. Tells Solr whether to optimize after the operation. synchronous Blocks request until import is completed. Default is false. reload-config If the configuration file has been changed and you wish to reload it without restarting Solr, run the command\u00a0http:\/\/localhost:8983\/solr\/dih\/dataimport?command=reload-config status This command returns statistics on the number of documents created, deleted, queries run, rows fetched, status, and so on. For example:\u00a0http:\/\/localhost:8983\/solr\/dih\/dataimport?command=status. show&#8211;config This command responds with configuration:\u00a0http:\/\/localhost:8983\/solr\/dih\/dataimport?command=show-config. Some Important Processors Entity processors extract data, transform it, and add it to a Solr index. Examples of entities include views or tables in a data store. Each processor has its own set of attributes, described in its own section below. In addition, there are several attributes common to all entities which may be specified: dataSource The name of a data source. If there are multiple data sources defined, use this attribute with the name of the data source for this entity. name Required. The unique name used to identify an entity. pk The primary key for the entity. It is optional, and required only when using delta-imports. It has no relation to the uniqueKey defined in\u00a0schema.xml\u00a0but they can both be the same. This attribute is mandatory if you do delta-imports and then refer to the column name in\u00a0${dataimporter.delta.&lt;column-name&gt;}\u00a0which is used as the primary key. processor Default is\u00a0SqlEntityProcessor. Required only if the datasource is not RDBMS. onError Defines what to do if an error is encountered. Permissible values are: abort Stops the import. skip Skips the current document. continue [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.aeologic.com\/blog\/ultimate-solr-guide-7-importing-structured-data-with-data-import-handler\/\" \/>\n<meta property=\"og:site_name\" content=\"Aeologic Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/AeoLogicTech\/\" \/>\n<meta property=\"article:published_time\" content=\"2020-01-03T09:54:34+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-03-18T08:11:50+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/01\/data-handler-in-solr.png\" \/>\n\t<meta property=\"og:image:width\" content=\"521\" \/>\n\t<meta property=\"og:image:height\" content=\"300\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Manoj Kumar\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@aeologictech\" \/>\n<meta name=\"twitter:site\" content=\"@aeologictech\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Manoj Kumar\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"11 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":[\"Article\",\"BlogPosting\"],\"@id\":\"https:\/\/www.aeologic.com\/blog\/ultimate-solr-guide-7-importing-structured-data-with-data-import-handler\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.aeologic.com\/blog\/ultimate-solr-guide-7-importing-structured-data-with-data-import-handler\/\"},\"author\":{\"name\":\"Manoj Kumar\",\"@id\":\"https:\/\/www.aeologic.com\/blog\/#\/schema\/person\/13549984ba8e5f441cc733ed20d7daa4\"},\"headline\":\"Importing data with Data Import Handler &#8211; Ultimate Solr Guide\",\"datePublished\":\"2020-01-03T09:54:34+00:00\",\"dateModified\":\"2020-03-18T08:11:50+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.aeologic.com\/blog\/ultimate-solr-guide-7-importing-structured-data-with-data-import-handler\/\"},\"wordCount\":2094,\"publisher\":{\"@id\":\"https:\/\/www.aeologic.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.aeologic.com\/blog\/ultimate-solr-guide-7-importing-structured-data-with-data-import-handler\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/01\/data-handler-in-solr.png\",\"keywords\":[\"apache solr\",\"Application Development\",\"data import handler\",\"DIH\",\"handler\",\"solr core\",\"solr handler\"],\"articleSection\":[\"Solr\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.aeologic.com\/blog\/ultimate-solr-guide-7-importing-structured-data-with-data-import-handler\/\",\"url\":\"https:\/\/www.aeologic.com\/blog\/ultimate-solr-guide-7-importing-structured-data-with-data-import-handler\/\",\"name\":\"Importing data with Data Import Handler - Ultimate Solr Guide - Aeologic Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.aeologic.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.aeologic.com\/blog\/ultimate-solr-guide-7-importing-structured-data-with-data-import-handler\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.aeologic.com\/blog\/ultimate-solr-guide-7-importing-structured-data-with-data-import-handler\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/01\/data-handler-in-solr.png\",\"datePublished\":\"2020-01-03T09:54:34+00:00\",\"dateModified\":\"2020-03-18T08:11:50+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.aeologic.com\/blog\/ultimate-solr-guide-7-importing-structured-data-with-data-import-handler\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.aeologic.com\/blog\/ultimate-solr-guide-7-importing-structured-data-with-data-import-handler\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.aeologic.com\/blog\/ultimate-solr-guide-7-importing-structured-data-with-data-import-handler\/#primaryimage\",\"url\":\"https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/01\/data-handler-in-solr.png\",\"contentUrl\":\"https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/01\/data-handler-in-solr.png\",\"width\":521,\"height\":300},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.aeologic.com\/blog\/ultimate-solr-guide-7-importing-structured-data-with-data-import-handler\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.aeologic.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Importing data with Data Import Handler &#8211; Ultimate Solr Guide\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.aeologic.com\/blog\/#website\",\"url\":\"https:\/\/www.aeologic.com\/blog\/\",\"name\":\"Aeologic Blog\",\"description\":\"Aeologic\",\"publisher\":{\"@id\":\"https:\/\/www.aeologic.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.aeologic.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.aeologic.com\/blog\/#organization\",\"name\":\"AeoLogic Technologies\",\"url\":\"https:\/\/www.aeologic.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.aeologic.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2022\/05\/new-logo-aeo.jpg\",\"contentUrl\":\"https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2022\/05\/new-logo-aeo.jpg\",\"width\":385,\"height\":162,\"caption\":\"AeoLogic Technologies\"},\"image\":{\"@id\":\"https:\/\/www.aeologic.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/AeoLogicTech\/\",\"https:\/\/x.com\/aeologictech\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.aeologic.com\/blog\/#\/schema\/person\/13549984ba8e5f441cc733ed20d7daa4\",\"name\":\"Manoj Kumar\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.aeologic.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/24ce77602da5eb5715d74a95733f6c7548e2af73f5a493f9bc0bf55f611d025e?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/24ce77602da5eb5715d74a95733f6c7548e2af73f5a493f9bc0bf55f611d025e?s=96&d=mm&r=g\",\"caption\":\"Manoj Kumar\"},\"description\":\"Manoj Kumar is a seasoned Digital Marketing Manager and passionate Tech Blogger with deep expertise in SEO, AI trends, and emerging digital technologies. He writes about innovative solutions that drive growth and transformation across industry. Featured on - YOURSTORY | TECHSLING | ELEARNINGINDUSTRY | DATASCIENCECENTRAL | TIMESOFINDIA | MEDIUM | DATAFLOQ\",\"sameAs\":[\"https:\/\/www.aeologic.com\/\",\"https:\/\/www.linkedin.com\/in\/manoj-kumar-rajput\/\"],\"url\":\"https:\/\/www.aeologic.com\/blog\/author\/manoj\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Importing data with Data Import Handler - Ultimate Solr Guide - Aeologic Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.aeologic.com\/blog\/ultimate-solr-guide-7-importing-structured-data-with-data-import-handler\/","og_locale":"en_US","og_type":"article","og_title":"Importing data with Data Import Handler - Ultimate Solr Guide - Aeologic Blog","og_description":"Introduction Hello everyone! We are back with another post. Today we will discuss in detail another important aspect used in many enterprise-grade applications. All organizations big and small in evidently store data some form of structured data store. Data import handler provides a mechanism for importing content of that datastore and indexing it. In addition to it, there can be HTTP\/RSS based data store along with ATOM feeds, email repositories, structures XML, so on and so forth. How DIH is configured? DIH handler is ideally configured in solrconfig.xml. The handler configuration itself is easy and demands less work. However, when implementing with varied types of data stores, the intrinsic complexity of it becomes pretty evident. For instance, Data Import Handler can be configured as follows : The config file here defines the information like, how to fetch data, what to fetch, the document structure conceived etc. The below example shows how to extract fields from four tables defining a simple product database. More information about the parameters and options shown here will be described in the sections following : The first element is the dataSource, in this case an HSQLDB database. The path to the JDBC driver and the JDBC URL and login credentials are all specified here. Other permissible attributes include whether or not to autocommit to Solr, the batchsize used in the JDBC connection, and a\u00a0readOnly flag. The password attribute is optional if there is no password set for the DB. Alternately the password can be encrypted as follows. This is the value obtained as a result of the command\u00a0openssl enc -aes-128-cbc -a -salt -in pwd.txt password=\"U2FsdGVkX18QMjY0yfCqlfBMvAB4d3XkwY96L7gfO2o=\". When the password is encrypted, you must provide an extra attribute\u00a0encryptKeyFile=\"\/location\/of\/encryptionkey\". This file should a text file with a single line containing the encrypt\/decrypt password. A\u00a0document\u00a0element follows, containing multiple\u00a0entity\u00a0elements. Note that\u00a0entity\u00a0elements can be nested, and this allows the entity relationships in the sample database to be mirrored here, so that we can generate a denormalized Solr record which may include multiple features for one item, for instance. The possible attributes for the\u00a0entity\u00a0element are described in later sections. Entity elements may contain one or more\u00a0field\u00a0elements, which map the data source field names to Solr fields, and optionally specify per-field transformations. This entity is the\u00a0root\u00a0entity. This entity is nested and reflects the one-to-many relationship between an item and its multiple features. Note the use of variables;\u00a0${item.ID}\u00a0is the value of the column &#8216;ID&#8217; for the current item (item referring to the entity name). Datasources can still be specified in\u00a0solrconfig.xml. These must be specified in the defaults section of the handler in\u00a0solrconfig.xml. However, these are not parsed until the main configuration is loaded. The entire configuration itself can be passed as a request parameter using the\u00a0dataConfig\u00a0parameter rather than using a file. When configuration errors are encountered, the error message is returned in XML format. A\u00a0reload-config\u00a0command is also supported, which is useful for validating a new configuration file, or if you want to specify a file, load it, and not have it reloaded again on import. If there is an\u00a0xml\u00a0mistake in the configuration a user-friendly message is returned in\u00a0xml\u00a0format. You can then fix the problem and do a\u00a0reload-config. Important Commands abort Aborts an ongoing operation. For example:\u00a0http:\/\/localhost:8983\/solr\/dih\/dataimport?command=abort. delta-import For incremental imports and change detection. Only the\u00a0SqlEntityProcessor\u00a0supports delta imports. For example:\u00a0http:\/\/localhost:8983\/solr\/dih\/dataimport?command=delta-import. This command supports the same\u00a0clean,\u00a0commit,\u00a0optimize\u00a0and\u00a0debug\u00a0parameters as\u00a0full-import\u00a0command described below. full-import A Full Import operation can be started with a URL such as\u00a0http:\/\/localhost:8983\/solr\/dih\/dataimport?command=full-import. The command returns immediately. The operation will be started in a new thread and the\u00a0status\u00a0attribute in the response should be shown as\u00a0busy. The operation may take some time depending on the size of dataset. Queries to Solr are not blocked during full-imports. When a\u00a0full-import\u00a0command is executed, it stores the start time of the operation in a file located at\u00a0conf\/dataimport.properties. This stored timestamp is used when a\u00a0delta-import\u00a0operation is executed. Commands available to\u00a0full-import\u00a0are: clean Default is true. Tells whether to clean up the index before the indexing is started. commit Default is true. Tells whether to commit after the operation. debug Default is false. Runs the command in debug mode and is used by the interactive development mode. Note that in debug mode, documents are never committed automatically. If you want to run debug mode and commit the results too, add\u00a0commit=true\u00a0as a request parameter. entity The name of an entity directly under the\u00a0&lt;document&gt;\u00a0tag in the configuration file. Use this to execute one or more entities selectively. Multiple &#8220;entity&#8221; parameters can be passed on to run multiple entities at once. If nothing is passed, all entities are executed. optimize Default is true. Tells Solr whether to optimize after the operation. synchronous Blocks request until import is completed. Default is false. reload-config If the configuration file has been changed and you wish to reload it without restarting Solr, run the command\u00a0http:\/\/localhost:8983\/solr\/dih\/dataimport?command=reload-config status This command returns statistics on the number of documents created, deleted, queries run, rows fetched, status, and so on. For example:\u00a0http:\/\/localhost:8983\/solr\/dih\/dataimport?command=status. show&#8211;config This command responds with configuration:\u00a0http:\/\/localhost:8983\/solr\/dih\/dataimport?command=show-config. Some Important Processors Entity processors extract data, transform it, and add it to a Solr index. Examples of entities include views or tables in a data store. Each processor has its own set of attributes, described in its own section below. In addition, there are several attributes common to all entities which may be specified: dataSource The name of a data source. If there are multiple data sources defined, use this attribute with the name of the data source for this entity. name Required. The unique name used to identify an entity. pk The primary key for the entity. It is optional, and required only when using delta-imports. It has no relation to the uniqueKey defined in\u00a0schema.xml\u00a0but they can both be the same. This attribute is mandatory if you do delta-imports and then refer to the column name in\u00a0${dataimporter.delta.&lt;column-name&gt;}\u00a0which is used as the primary key. processor Default is\u00a0SqlEntityProcessor. Required only if the datasource is not RDBMS. onError Defines what to do if an error is encountered. Permissible values are: abort Stops the import. skip Skips the current document. continue [&hellip;]","og_url":"https:\/\/www.aeologic.com\/blog\/ultimate-solr-guide-7-importing-structured-data-with-data-import-handler\/","og_site_name":"Aeologic Blog","article_publisher":"https:\/\/www.facebook.com\/AeoLogicTech\/","article_published_time":"2020-01-03T09:54:34+00:00","article_modified_time":"2020-03-18T08:11:50+00:00","og_image":[{"width":521,"height":300,"url":"https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/01\/data-handler-in-solr.png","type":"image\/png"}],"author":"Manoj Kumar","twitter_card":"summary_large_image","twitter_creator":"@aeologictech","twitter_site":"@aeologictech","twitter_misc":{"Written by":"Manoj Kumar","Est. reading time":"11 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":["Article","BlogPosting"],"@id":"https:\/\/www.aeologic.com\/blog\/ultimate-solr-guide-7-importing-structured-data-with-data-import-handler\/#article","isPartOf":{"@id":"https:\/\/www.aeologic.com\/blog\/ultimate-solr-guide-7-importing-structured-data-with-data-import-handler\/"},"author":{"name":"Manoj Kumar","@id":"https:\/\/www.aeologic.com\/blog\/#\/schema\/person\/13549984ba8e5f441cc733ed20d7daa4"},"headline":"Importing data with Data Import Handler &#8211; Ultimate Solr Guide","datePublished":"2020-01-03T09:54:34+00:00","dateModified":"2020-03-18T08:11:50+00:00","mainEntityOfPage":{"@id":"https:\/\/www.aeologic.com\/blog\/ultimate-solr-guide-7-importing-structured-data-with-data-import-handler\/"},"wordCount":2094,"publisher":{"@id":"https:\/\/www.aeologic.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.aeologic.com\/blog\/ultimate-solr-guide-7-importing-structured-data-with-data-import-handler\/#primaryimage"},"thumbnailUrl":"https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/01\/data-handler-in-solr.png","keywords":["apache solr","Application Development","data import handler","DIH","handler","solr core","solr handler"],"articleSection":["Solr"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.aeologic.com\/blog\/ultimate-solr-guide-7-importing-structured-data-with-data-import-handler\/","url":"https:\/\/www.aeologic.com\/blog\/ultimate-solr-guide-7-importing-structured-data-with-data-import-handler\/","name":"Importing data with Data Import Handler - Ultimate Solr Guide - Aeologic Blog","isPartOf":{"@id":"https:\/\/www.aeologic.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.aeologic.com\/blog\/ultimate-solr-guide-7-importing-structured-data-with-data-import-handler\/#primaryimage"},"image":{"@id":"https:\/\/www.aeologic.com\/blog\/ultimate-solr-guide-7-importing-structured-data-with-data-import-handler\/#primaryimage"},"thumbnailUrl":"https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/01\/data-handler-in-solr.png","datePublished":"2020-01-03T09:54:34+00:00","dateModified":"2020-03-18T08:11:50+00:00","breadcrumb":{"@id":"https:\/\/www.aeologic.com\/blog\/ultimate-solr-guide-7-importing-structured-data-with-data-import-handler\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.aeologic.com\/blog\/ultimate-solr-guide-7-importing-structured-data-with-data-import-handler\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.aeologic.com\/blog\/ultimate-solr-guide-7-importing-structured-data-with-data-import-handler\/#primaryimage","url":"https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/01\/data-handler-in-solr.png","contentUrl":"https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/01\/data-handler-in-solr.png","width":521,"height":300},{"@type":"BreadcrumbList","@id":"https:\/\/www.aeologic.com\/blog\/ultimate-solr-guide-7-importing-structured-data-with-data-import-handler\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.aeologic.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Importing data with Data Import Handler &#8211; Ultimate Solr Guide"}]},{"@type":"WebSite","@id":"https:\/\/www.aeologic.com\/blog\/#website","url":"https:\/\/www.aeologic.com\/blog\/","name":"Aeologic Blog","description":"Aeologic","publisher":{"@id":"https:\/\/www.aeologic.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.aeologic.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.aeologic.com\/blog\/#organization","name":"AeoLogic Technologies","url":"https:\/\/www.aeologic.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.aeologic.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2022\/05\/new-logo-aeo.jpg","contentUrl":"https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2022\/05\/new-logo-aeo.jpg","width":385,"height":162,"caption":"AeoLogic Technologies"},"image":{"@id":"https:\/\/www.aeologic.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/AeoLogicTech\/","https:\/\/x.com\/aeologictech"]},{"@type":"Person","@id":"https:\/\/www.aeologic.com\/blog\/#\/schema\/person\/13549984ba8e5f441cc733ed20d7daa4","name":"Manoj Kumar","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.aeologic.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/24ce77602da5eb5715d74a95733f6c7548e2af73f5a493f9bc0bf55f611d025e?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/24ce77602da5eb5715d74a95733f6c7548e2af73f5a493f9bc0bf55f611d025e?s=96&d=mm&r=g","caption":"Manoj Kumar"},"description":"Manoj Kumar is a seasoned Digital Marketing Manager and passionate Tech Blogger with deep expertise in SEO, AI trends, and emerging digital technologies. He writes about innovative solutions that drive growth and transformation across industry. Featured on - YOURSTORY | TECHSLING | ELEARNINGINDUSTRY | DATASCIENCECENTRAL | TIMESOFINDIA | MEDIUM | DATAFLOQ","sameAs":["https:\/\/www.aeologic.com\/","https:\/\/www.linkedin.com\/in\/manoj-kumar-rajput\/"],"url":"https:\/\/www.aeologic.com\/blog\/author\/manoj\/"}]}},"_links":{"self":[{"href":"https:\/\/www.aeologic.com\/blog\/wp-json\/wp\/v2\/posts\/386","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.aeologic.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.aeologic.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.aeologic.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.aeologic.com\/blog\/wp-json\/wp\/v2\/comments?post=386"}],"version-history":[{"count":0,"href":"https:\/\/www.aeologic.com\/blog\/wp-json\/wp\/v2\/posts\/386\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.aeologic.com\/blog\/wp-json\/wp\/v2\/media\/395"}],"wp:attachment":[{"href":"https:\/\/www.aeologic.com\/blog\/wp-json\/wp\/v2\/media?parent=386"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.aeologic.com\/blog\/wp-json\/wp\/v2\/categories?post=386"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.aeologic.com\/blog\/wp-json\/wp\/v2\/tags?post=386"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}