title: What is difference between Post Tool and Index Handlers?
body: <p>I have a JSON documents which needs to be indexed in Solr. The document looks like this:</p>
  
  <pre><code>{  
     "id":"1",
     "prop":null,
     "path":"1.parent",
     "_childDocuments_":[  
        {  
           "id":"2",
           "path":"2.parent.child"
        }
     ]
  }
  </code></pre>
  
  <p>It contains parent-child relationship structure denoted by <code>_childDocuments_</code> key.</p>
  
  <p>When I insert the documents in Solr via Post Tool, i.e., <code>./bin/post -c coreName data.json</code> and query the Solr, then I get following response from Solr:</p>
  
  <pre><code>$ curl 'http://localhost:8983/solr/coreName/select?indent=on&amp;q=*:*&amp;wt=json'
  {
    "responseHeader":{
      "status":0,
      "QTime":0,
      "params":{
        "q":"*:*",
        "indent":"on",
        "wt":"json"}},
    "response":{"numFound":1,"start":0,"docs":[
        {
          "id":"1",
          "path":["1.parent"],
          "_childDocuments_.id":[2],
          "_childDocuments_.path":["2.parent.child"],
          "_version_":1566718833663672320}]
    }}
  </code></pre>
  
  <p>But when I try to insert the same JSON document via Index Handler, i.e., <code>curl</code> - </p>
  
  <pre><code>$ curl "http://localhost:8983/solr/coreName/update?commit=true" -H 'Content-type:application/json' --data-binary "@1.json"
  {"responseHeader":{"status":400,"QTime":56},"error":{"metadata":["error-class","org.apache.solr.common.SolrException","root-error-class","org.apache.solr.common.SolrException"],"msg":"Unknown command 'id' at [11]","code":400}}
  </code></pre>
  
  <p>I get <code>SolrException</code>. But if I put the JSON in array, then it shows another error, i.e.,</p>
  
  <pre><code>[{  
     "id":"1",
     "prop": null,
     "path":"1.parent",
     "_childDocuments_":[  
        {  
           "id":"2",
           "path":"2.parent.child"
        }
     ]
  }]
  </code></pre>
  
  <p>Error:</p>
  
  <pre><code>$ curl 'http://localhost:8983/solr/coreName/update?commit=true' -H 'Content-type:application/json' --data "@/home/knoldus/practice/solr/1.json"
  {"responseHeader":{"status":500,"QTime":3},"error":{"trace":"java.lang.NullPointerException\n\tat org.apache.solr.update.processor.AddSchemaFieldsUpdateProcessorFactory$AddSchemaFieldsUpdateProcessor.mapValueClassesToFieldType(AddSchemaFieldsUpdateProcessorFactory.java:370)\n\tat org.apache.solr.update.processor.AddSchemaFieldsUpdateProcessorFactory$AddSchemaFieldsUpdateProcessor.processAdd(AddSchemaFieldsUpdateProcessorFactory.java:288)\n\tat org.apache.solr.update.processor.UpdateRequestProcessor.processAdd(UpdateRequestProcessor.java:48)\n\tat org.apache.solr.update.processor.FieldMutatingUpdateProcessor.processAdd(FieldMutatingUpdateProcessor.java:118)\n\tat org.apache.solr.update.processor.UpdateRequestProcessor.processAdd(UpdateRequestProcessor.java:48)\n\tat org.apache.solr.update.processor.FieldMutatingUpdateProcessor.processAdd(FieldMutatingUpdateProcessor.java:118)\n\tat org.apache.solr.update.processor.UpdateRequestProcessor.processAdd(UpdateRequestProcessor.java:48)\n\tat org.apache.solr.update.processor.FieldMutatingUpdateProcessor.processAdd(FieldMutatingUpdateProcessor.java:118)\n\tat org.apache.solr.update.processor.UpdateRequestProcessor.processAdd(UpdateRequestProcessor.java:48)\n\tat org.apache.solr.update.processor.FieldMutatingUpdateProcessor.processAdd(FieldMutatingUpdateProcessor.java:118)\n\tat org.apache.solr.update.processor.UpdateRequestProcessor.processAdd(UpdateRequestProcessor.java:48)\n\tat org.apache.solr.update.processor.FieldNameMutatingUpdateProcessorFactory$1.processAdd(FieldNameMutatingUpdateProcessorFactory.java:74)\n\tat org.apache.solr.update.processor.UpdateRequestProcessor.processAdd(UpdateRequestProcessor.java:48)\n\tat org.apache.solr.update.processor.FieldMutatingUpdateProcessor.processAdd(FieldMutatingUpdateProcessor.java:118)\n\tat org.apache.solr.update.processor.UpdateRequestProcessor.processAdd(UpdateRequestProcessor.java:48)\n\tat org.apache.solr.update.processor.AbstractDefaultValueUpdateProcessorFactory$DefaultValueUpdateProcessor.processAdd(AbstractDefaultValueUpdateProcessorFactory.java:91)\n\tat org.apache.solr.handler.loader.JsonLoader$SingleThreadedJsonLoader.handleAdds(JsonLoader.java:492)\n\tat org.apache.solr.handler.loader.JsonLoader$SingleThreadedJsonLoader.processUpdate(JsonLoader.java:139)\n\tat org.apache.solr.handler.loader.JsonLoader$SingleThreadedJsonLoader.load(JsonLoader.java:115)\n\tat org.apache.solr.handler.loader.JsonLoader.load(JsonLoader.java:78)\n\tat org.apache.solr.handler.UpdateRequestHandler$1.load(UpdateRequestHandler.java:97)\n\tat org.apache.solr.handler.ContentStreamHandlerBase.handleRequestBody(ContentStreamHandlerBase.java:68)\n\tat org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:166)\n\tat org.apache.solr.core.SolrCore.execute(SolrCore.java:2306)\n\tat org.apache.solr.servlet.HttpSolrCall.execute(HttpSolrCall.java:658)\n\tat org.apache.solr.servlet.HttpSolrCall.call(HttpSolrCall.java:464)\n\tat org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:345)\n\tat org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:296)\n\tat org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1691)\n\tat org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:582)\n\tat org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)\n\tat org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548)\n\tat org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:226)\n\tat org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1180)\n\tat org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:512)\n\tat org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)\n\tat org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1112)\n\tat org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)\n\tat org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:213)\n\tat org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:119)\n\tat org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:134)\n\tat org.eclipse.jetty.server.Server.handle(Server.java:534)\n\tat org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:320)\n\tat org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:251)\n\tat org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:273)\n\tat org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:95)\n\tat org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:93)\n\tat org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.executeProduceConsume(ExecuteProduceConsume.java:303)\n\tat org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceConsume(ExecuteProduceConsume.java:148)\n\tat org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:136)\n\tat org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:671)\n\tat org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:589)\n\tat java.lang.Thread.run(Thread.java:745)\n","code":500}}
  </code></pre>
  
  <p>So, I have to remove <code>"prop": null</code> as well or make it an empty string, like this:</p>
  
  <pre><code>[{  
     "id":"1",
     "prop": "",
     "path":"1.parent",
     "_childDocuments_":[  
        {  
           "id":"2",
           "path":"2.parent.child"
        }
     ]
  }]
  </code></pre>
  
  <p>After making these modifications, when I insert the JSON doc. in Solr via <code>curl</code>, then it works fine.</p>
  
  <pre><code>$ curl 'http://localhost:8983/solr/coreName/update?commit=true' -H 'Content-type:application/json' --data "@/home/knoldus/practice/solr/1.json"
  {"responseHeader":{"status":0,"QTime":851}}
  </code></pre>
  
  <p>And I get following response from Solr query:</p>
  
  <pre><code>$ curl 'http://localhost:8983/solr/coreName/select?indent=on&amp;q=*:*&amp;wt=json'
  {
    "responseHeader":{
      "status":0,
      "QTime":1,
      "params":{
        "q":"*:*",
        "indent":"on",
        "wt":"json"}},
    "response":{"numFound":2,"start":0,"docs":[
        {
          "id":"2",
          "path":["2.parent.child"]},
        {
          "id":"1",
          "path":["1.parent"],
          "_version_":1566719240059224064}]
    }}
  </code></pre>
  
  <p>But here again I see a difference that <code>_childDocuments_</code> have been indexed as separate documents.</p>
  
  <p>So, I have following questions on two different methods of data indexing in Solr:</p>
  
  <ol>
  <li>Why Post Tool <code>./bin/post</code> does not index <code>_childDocuments_</code> separately like Request Handler <code>/update</code>?</li>
  <li>Why Request Handler <code>/update</code> requires JSON document to be wrapped in array?</li>
  <li>And last, why Request Handler <code>/update</code> cannot handle <code>null</code> values whereas Post Tool can?</li>
  </ol>