Solr extract to upload documents not working using Solr 8.10.1

188 Views Asked by At

We have an existing application that currently uses Solr 3.6.1 for indexing and searching of documents. Using Solr 3.6.1,everything works fine.

I built a Solr 8.10.1 server and when I try to upload documents to a Solr collection in 8.10.1, I get a "Data is invalid at root level" error. Any help with would be appreciated. Thanks

CODE:

ISolrOperations<GetPHP> solr = ServiceLocator.Current.GetInstance<ISolrOperations<GetPHP>>();
                                            var response =
                                                    solr.Extract(
                                                    new ExtractParameters(file, nextDocFile)
                                                    {
                                                        ExtractFormat = ExtractFormat.Text,
                                                        ExtractOnly = false,
                                                        AutoCommit = true
                                                    });

ERROR LOG:

Exception Type: XmlException Error in: http://localhost:63408/document/new_document.aspx?uID=2081&dType=PHP&txtPath=%2fContribution+Folders%2fPHP%2f00+-++CLOSED+FILES%2f01-Intelligence%2f01-Personnel Error Message: Data at the root level is invalid. Line 1, position 1.
Error Source: System.Xml
StackTrace:    at System.Xml.XmlTextReaderImpl.Throw(Exception e)
   at System.Xml.XmlTextReaderImpl.Throw(String res, String arg)
   at System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace()
   at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
   at System.Xml.XmlTextReaderImpl.Read()
   at System.Xml.Linq.XDocument.Load(XmlReader reader, LoadOptions options)
   at System.Xml.Linq.XDocument.Parse(String text, LoadOptions options)
   at System.Xml.Linq.XDocument.Parse(String text)
   at SolrNet.Impl.SolrBasicServer`1.SendAndParseExtract(ISolrCommand cmd)
   at SolrNet.Impl.SolrBasicServer`1.Extract(ExtractParameters parameters)
   at SolrNet.Impl.SolrServer`1.Extract(ExtractParameters parameters)
   at xyz_app.Document.new_document.Upload_File() in
1

There are 1 best solutions below

0
George On

Solr switched to JSON as the default response writer in version 7.0. Before that it was XML.

My application was expecting XML, but was receiving a JSON respnse from Solr

SOLUTION:

I made the following update to conf/solrconfig.xml in each of my Solr cores.

CHANGE line below

<queryResponseWriter name="json" class="solr.JSONResponseWriter">

TO

<queryResponseWriter name="xml"
    default="true"
  class="solr.XMLResponseWriter" />

This causes SOLR to return XML instead of JSON