简体   繁体   English

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

[英]solrnet server connection error. The remote server returned an error: (400) Bad Request

Running on Tomcate windows xp with solrNet with using solrnet.dll and Microsoft.Practices.ServiceLocation.dll and I am getting error The Remote server return an error.(400) Bad Request. 使用solrnet.dll和Microsoft.Practices.ServiceLocation.dll在带有solrNet的Tomcate Windows XP上运行,并且出现错误远程服务器返回错误。(400)错误的请求。

when add content on this code 在此代码上添加内容时

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

    });

i am using code below... 我正在使用下面的代码...

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();
    }

This error is probably related to a mismatch with your Solr schema.xml <fields> settings and your Article class. 此错误可能与Solr schema.xml <fields>设置和Article类不匹配有关。 You should be able to debug your program and examine the Bad Request error for more details on what the issue is. 您应该能够调试程序并检查Bad Request错误,以获取有关问题所在的更多详细信息。 Or you can examine the server logs for Solr (in your hosting container eg Jetty, Tomcat) for more details as well. 或者,您也可以检查服务器日志中的Solr(在您的托管容器中,例如Jetty,Tomcat),以获取更多详细信息。

Additionally, I would change your Tags property on the Article class to be the more generic ICollection like the multiValued examples on the SolrNet Mapping wiki . 另外,我将您在Article类上的Tags属性更改为更通用的ICollectionSolrNet Mapping Wiki上的multiValued示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 远程服务器返回错误:(400)错误请求? - The remote server returned an error: (400) Bad Request? 远程服务器返回错误(400)错误的请求 - the remote server returned an error (400) bad request (400)错误的请求-&gt;远程服务器返回错误:(400)错误的请求 - (400) Bad Request -> The remote server returned an error: (400) Bad Request Linq To Twitter错误-“远程服务器返回错误:(400)错误的请求” - Linq To Twitter error - “The remote server returned an error: (400) Bad Request” WebClient UploadFile远程服务器返回错误:(400)错误的请求 - WebClient UploadFile The remote server returned an error: (400) Bad Request 远程服务器返回错误(400)错误的请求,状态为ProtocolError - The remote server returned an error (400) Bad Request, status ProtocolError C#FCM:远程服务器返回错误:(400)错误的请求 - C# FCM : The remote server returned an error: (400) Bad Request 远程服务器返回错误:(400)错误请求。 - The remote server returned an error: (400) Bad Request. 如何修复:远程服务器返回错误:(400) 错误请求 - HOW TO FIX: The remote server returned an error: (400) Bad Request HttpWebResponse:远程服务器返回错误:(400) 错误请求 - HttpWebResponse: The remote server returned an error: (400) Bad Request
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM