【问题标题】:Solr extract to upload documents not working using Solr 8.10.1Solr 提取上传文档无法使用 Solr 8.10.1
【发布时间】:2021-11-16 20:09:25
【问题描述】:

我们有一个现有的应用程序,目前使用 Solr 3.6.1 来索引和搜索文档。使用 Solr 3.6.1,一切正常。

我构建了一个 Solr 8.10.1 服务器,当我尝试将文档上传到 8.10.1 中的 Solr 集合时,我收到“数据在根级别无效”错误。任何帮助将不胜感激。 谢谢

代码:

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

错误日志:

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

【问题讨论】:

  • 来自 ASP.NET C# 应用程序的代码。我的研究表明 Solr 8.x 在我的代码正在寻找 XML 时返回 JSON。我不知道如何在 Solr 提取函数中编写参数。也可能是其他原因导致问题,

标签: c# solr solrnet


【解决方案1】:

Solr 在 7.0 版中切换到 JSON 作为默认响应编写器。在此之前它是 XML。

我的应用程序期待 XML,但收到了来自 Solr 的 JSON 响应

解决方案:

我对我的每个 Solr 内核中的 conf/solrconfig.xml 进行了以下更新。

更改下面的行

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

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

这会导致 SOLR 返回 XML 而不是 JSON

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-02
    • 2011-06-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-28
    相关资源
    最近更新 更多