title: Importing data from CSV, XML or Json files to solr using dataimport
body: <p>I am trying to import data from files like CSV, XML and Json to solr core, I am new to solr so this might be a straightforward to some but for me I have tried many online suggestions but not getting the desired result.</p>
  
  <p>So I have a json file and I have enabled dataimport by adding the following requestHandler to solrconfig.xml:</p>
  
  <pre><code>&lt;requestHandler  name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler"&gt;
      &lt;lst name="defaults"&gt;
          &lt;str name="config"&gt;solr-data-config.xml&lt;/str&gt;
      &lt;/lst&gt;
  &lt;/requestHandler&gt;
  </code></pre>
  
  <p>And in the solr-data-config.xml:</p>
  
  <pre><code>&lt;dataConfig&gt;
  &lt;dataSource name="dfs" type="FileDataSource"/&gt;
  &lt;document&gt;
      &lt;entity name="sourcefile" processor="FileListEntityProcessor" fileName=".*" rootEntity="false" baseDir="${solr.install.dir}/example/exampledocs"&gt;
          &lt;entity name="entryline" processor="LineEntityProcessor" url="${sourcefile.fileAbsolutePath}" rootEntity="true" dataSource="fds" separator=","/&gt;
      &lt;/entity&gt;
  &lt;/document&gt;
  </code></pre>
  
  <p></p>
  
  <p>The updated version:</p>
  
  <pre><code>    &lt;dataConfig&gt;
       &lt;script&gt;&lt;![CDATA[
      function CategoryPieces(row) {
        var pieces = row.get('manu_id_s').split('/');
        var arr = new Array();
        for (var i=0; i &lt; pieces.length; i++) {
          row.put('manu_id_s' + i, pieces[i].trim());
          arr[i] = pieces[i].trim();
        }
        row.put('manu_id_s', (pieces.length - 1).toFixed());
        row.put('manu_id_s', arr.join('/'));
        row.put('manu_id_s', arr.join('/'));
        return row;
    }
       ]]&gt;&lt;/script&gt;
    &lt;dataSource type="FileDataSource" /&gt;
    &lt;document&gt;
      &lt;entity
        name="document"
        processor="FileListEntityProcessor"
        baseDir="${solr.install.dir}/example/exampledocs/khaled"
        fileName=".*.xml$"
        recursive="false"
        rootEntity="false"
        dataSource="null"&gt;
        &lt;entity
        name="test"
          processor="XPathEntityProcessor"
          transformer="script:CategoryPieces"
          url="${document.fileAbsolutePath}"
          useSolrAddSchema="true"
          stream="true"&gt;
        &lt;/entity&gt;
      &lt;/entity&gt;
    &lt;/document&gt;
  &lt;/dataConfig&gt;
  </code></pre>
  
  <p>And I have added a json, csv and xml files to the path, in the ui of solr when I use the dataimport it says that e.g. Requests: 0 , Fetched: 26 , Skipped: 0 , Processed: 0 and nothing in the logs, can someone advice how to add the data in the file to solr?</p>
  
  <p>Here is my sample data in the xml file:</p>
  
  <pre><code>&lt;add&gt;
  &lt;doc&gt;
    &lt;field name="id"&gt;USD&lt;/field&gt;
    &lt;field name="name"&gt;One Dollar&lt;/field&gt;
    &lt;field name="manu"&gt;Bank of America&lt;/field&gt;
    &lt;field name="manu_id_s"&gt;boa&lt;/field&gt;
    &lt;field name="cat"&gt;currency&lt;/field&gt;
    &lt;field name="features"&gt;Coins and notes&lt;/field&gt;
    &lt;field name="price_c"&gt;1,USD&lt;/field&gt;
    &lt;field name="inStock"&gt;true&lt;/field&gt;
  &lt;/doc&gt;
  
  &lt;doc&gt;
    &lt;field name="id"&gt;EUR&lt;/field&gt;
    &lt;field name="name"&gt;One Euro&lt;/field&gt;
    &lt;field name="manu"&gt;European Union&lt;/field&gt;
    &lt;field name="manu_id_s"&gt;eu&lt;/field&gt;
    &lt;field name="cat"&gt;currency&lt;/field&gt;
    &lt;field name="features"&gt;Coins and notes&lt;/field&gt;
    &lt;field name="price_c"&gt;1,EUR&lt;/field&gt;
    &lt;field name="inStock"&gt;true&lt;/field&gt;
  &lt;/doc&gt;
  
  &lt;doc&gt;
    &lt;field name="id"&gt;GBP&lt;/field&gt;
    &lt;field name="name"&gt;One British Pound&lt;/field&gt;
    &lt;field name="manu"&gt;U.K.&lt;/field&gt;
    &lt;field name="manu_id_s"&gt;uk&lt;/field&gt;
    &lt;field name="cat"&gt;currency&lt;/field&gt;
    &lt;field name="features"&gt;Coins and notes&lt;/field&gt;
    &lt;field name="price_c"&gt;1,GBP&lt;/field&gt;
    &lt;field name="inStock"&gt;true&lt;/field&gt;
  &lt;/doc&gt;
  
  &lt;doc&gt;
    &lt;field name="id"&gt;NOK&lt;/field&gt;
    &lt;field name="name"&gt;One Krone&lt;/field&gt;
    &lt;field name="manu"&gt;Bank of Norway&lt;/field&gt;
    &lt;field name="manu_id_s"&gt;nor&lt;/field&gt;
    &lt;field name="cat"&gt;currency&lt;/field&gt;
    &lt;field name="features"&gt;Coins and notes&lt;/field&gt;
    &lt;field name="price_c"&gt;1,NOK&lt;/field&gt;
    &lt;field name="inStock"&gt;true&lt;/field&gt;
  &lt;/doc&gt;
  
  &lt;/add&gt;
  </code></pre>
  
  <p>Now the data returned from the query looks like:</p>
  
  <pre><code>{
    "responseHeader":{
      "status":0,
      "QTime":0,
      "params":{
        "q":"*:*",
        "_":"1547556805546"}},
    "response":{"numFound":4,"start":0,"docs":[
        {
          "manu_id_s":"boa",
          "id":"USD",
          "_version_":1622731088078045184},
        {
          "manu_id_s":"eu",
          "id":"EUR",
          "_version_":1622731088081190912},
        {
          "manu_id_s":"uk",
          "id":"GBP",
          "_version_":1622731088081190913},
        {
          "manu_id_s":"nor",
          "id":"NOK",
          "_version_":1622731088082239488}]
    }}
  </code></pre>