C# solrnet服务器连接错误。远程服务器返回错误:(400)请求错误

C# solrnet服务器连接错误。远程服务器返回错误:(400)请求错误,c#,solr,indexing,lucene.net,solrnet,C#,Solr,Indexing,Lucene.net,Solrnet,使用solrNet.dll和Microsoft.Practices.ServiceLocation.dll在Tomcate windows xp上运行,远程服务器返回错误。(400)错误请求 当添加此代码上的内容时 solr.Add(new Article() { _id = 1, _title = "My Laptop", _content = "My laptop is portable power station",

使用solrNet.dll和Microsoft.Practices.ServiceLocation.dll在Tomcate windows xp上运行,远程服务器返回错误。(400)错误请求

当添加此代码上的内容时

solr.Add(new Article()
    {
        _id = 1,
        _title = "My Laptop",
        _content = "My laptop is portable power station",
        _tags = new List<string>() {
        "laptop","computer","device"
        }

    });
solr.Add(新文章()
{
_id=1,
_title=“我的笔记本电脑”,
_content=“我的笔记本电脑是便携式电站”,
_标签=新列表(){
“笔记本电脑”、“计算机”、“设备”
}
});
我正在使用下面的代码

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SolrNet;
using SolrNet.Attributes;
using SolrNet.Commands.Parameters;
using Microsoft.Practices.ServiceLocation;

namespace solrIndex_creator
{

 class Article
  {
    [SolrUniqueKey("id1")]
    public int _id { get; set; }

    [SolrField("title1")]
    public string _title { get; set; }

    [SolrField("content1")]
    public string _content { get; set; }

    [SolrField("tag1")]
    public List<string> _tags { get; set; }

    ISolrOperations<Article> solr;

   public void _write_Data()
    {
      Startup.Init<Article>("http://localhost:8080/solr/");
      solr = ServiceLocator.Current.GetInstance<ISolrOperations<Article>>();

       solr.Add(new Article()
        {
            _id = 1,
            _title = "My Laptop",
            _content = "My laptop is portable power station",
            _tags = new List<string>() {
            "laptop","computer","device"
            }

        });

       solr.Add(new Article()
        {
            _id = 2,
            _title = "my iphone",
            _content = "my iphone consumes power",
            _tags = new List<string>() {   
                "phone",   
                "apple",  
                "device"  
            }
        });

        solr.Add(new Article()
        {
            _id = 3,
            _title = "your blackberry",
            _content = "your blackberry has an alt key",
            _tags = new List<string>() {   
            "phone",   
            "rim",  
            "device"  
            }
        });
        solr.Commit();
    }
使用系统;
使用System.Collections.Generic;
使用System.Linq;
使用系统文本;
使用SolrNet;
使用SolrNet.Attributes;
使用SolrNet.Commands.Parameters;
使用Microsoft.Practices.ServiceLocation;
名称空间solrIndex_创建者
{
班级文章
{
[SolrUniqueKey(“id1”)]
公共int_id{get;set;}
[索尔菲尔德(“标题1”)]
公共字符串_title{get;set;}
[索尔菲尔德(“内容1”)]
公共字符串_content{get;set;}
[索尔菲尔德(“tag1”)]
公共列表_标记{get;set;}
等值线解;
public void_write_Data()
{
Startup.Init(“http://localhost:8080/solr/");
solr=ServiceLocator.Current.GetInstance();
新增(新条款)
{
_id=1,
_title=“我的笔记本电脑”,
_content=“我的笔记本电脑是便携式电站”,
_标签=新列表(){
“笔记本电脑”、“计算机”、“设备”
}
});
新增(新条款)
{
_id=2,
_title=“我的iphone”,
_content=“我的iphone耗电”,
_标记=新列表(){
“电话”,
“苹果”,
“设备”
}
});
新增(新条款)
{
_id=3,
_title=“你的黑莓”,
_content=“你的黑莓手机有一个alt键”,
_标记=新列表(){
“电话”,
“边缘”,
“设备”
}
});
solr.Commit();
}

此错误可能与Solr schema.xml
设置和文章类不匹配有关。您应该能够调试程序并检查错误请求错误,以了解有关问题的详细信息。或者您可以检查Solr的服务器日志(在您的托管容器中,例如Jetty、Tomcat中)更多细节


此外,我会将Article类上的Tags属性更改为更通用的
ICollection
,就像上的多值示例一样。

thnks我已经解决了这个错误,但是当我提交类似solr.commit()的索引时,我收到了错误“org.apache.solr.common.SolrException:未知提交参数“waitFlush”)这是早期版本的SolrNet库和Solr 4.X版本的问题。您可以从构建服务器下载更高版本的SolrNet-(注意:单击Artifacts链接以获得可下载的zip文件)。+1从构建服务器下载时,我花了近一个小时来找出
Commit
上的异常。