【发布时间】:2018-03-30 21:56:24
【问题描述】:
我在:localhost:8983/solr/global 上使用Solar: 7.0.1
我正在使用SolrNET 0.8.1 和以下代码示例:
using SolrNet;
using Microsoft.Practices.ServiceLocation;
Startup.Init<SOLRModel>("http://localhost:8983/solr/global");
var solr = ServiceLocator.Current.GetInstance<ISolrOperations<SOLRModel>>();
var results = solr.Query(new SolrQuery("*:*&wt=xml")); // Throws Error Here.
我收到一个错误:
Data at the root level is invalid. Line 1, position 1.
我使用的是默认架构,也尝试过 techproducts 示例,得到相同的错误。
我可以导航到:http://localhost:8983/solr/global/select?q=:,我得到了正常的 JSON 响应。
使用&wt=xml 可以为我提供格式良好的 XML 响应:
<?xml version="1.0" encoding="UTF-8" ?>
- <response>
- <lst name="responseHeader">
<int name="status">0</int>
<int name="QTime">0</int>
- <lst name="params">
<str name="q">*:*</str>
<str name="wt">xml</str>
</lst>
</lst>
<result name="response" numFound="0" start="0" />
</response>
请有人告诉我在哪里可以解决这个错误。
【问题讨论】:
-
你确定 SolrNET 支持 XML 输出吗?听起来它可能期望 JSON 输出?
-
是的,XDocument、XElement 等等。请参阅:github.com/SolrNet/SolrNet/blob/master/SolrNet/Impl/… 作为示例。天气我是否使用'&wt=xml',错误存在。
-
你在 Solr 日志中得到了什么有用的信息吗?您可能指的是
*:*作为查询,而不是*.*。我不确定您是否应该在您的 URL 中包含global- 根据 SolrNet 文档,它似乎是由模型/模型名称提供的?这将给出 404,当尝试将返回的 404 HTML 解析为 XML 时会导致解析错误。 -
global 是核心名称,随机名称,我之前有techproducts,给出同样的错误。没有核心名称,我得到 404 not found。日志记录了我所做的错误,但不会针对查询,除非我犯了错误。
-
我也遇到了同样的问题。日志显示它存在以下问题:Error added field 'end'='2017-08-05'