Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The remote server returned an error: (400) Bad Request. when add docs to index

Tags:

solrnet

when i add docs to index, the page returns 400 bad request. And the solr has been start up and can get data from database. So i need put the data into index. However, it's failed always.


1) Here is code snippet of SolrBaseRepository

/// <summary>    
/// Base repository for Solr    
/// </summary>  
public class SolrBaseRepository  
{    
    /// <summary>    
    /// New instance of Solr    
    /// </summary>    
    /// <typeparam name="T">Specific type</typeparam>  
    public class Instance<T>    
    {    
        /// <summary>  
        /// Start Solr instance for a specific type  
        /// </summary>  
        public void Start()  
        {  
            var instances = Startup.Container.GetAllInstances(typeof (ISolrOperations<T>));  

            if (instances.Count() == 0)  
            {  
                Startup.Init<T>(Toolbox.SolrUrl);  
            }  
        }  

    }  
}  

2) here is main part of schemal.xml

<fields>    
    <field name="id" type="int" indexed="true" stored="true" required="true" />   
    <field name="firstname" type="text" indexed="true" stored="false"required="false" />   
    <field name="lastname" type="text" indexed="true" stored="false" required="false" />  
    <field name="position" type="text" indexed="true" stored="false" required="false" />  
    <field name="text" type="text" indexed="true" stored="false" multiValued="true" />  
</fields>  
<copyField source="firstname" dest="text" />    
<copyField source="lastname" dest="text" />    
<copyField source="position" dest="text" />    
<uniqueKey>id</uniqueKey>    
<defaultSearchField>text</defaultSearchField>    
<solrQueryParser defaultOperator="AND" />     

3) solrurl: http://localhost:8080/solr

<appSettings>  
<add key="SolrUrl" value="http://localhost:8080/solr"/>  
</appSettings>  

4) error is here:

/// <summary>  
/// Add all players to the index  
/// </summary>  
public void IndexPlayers()  
{  
    new SolrBaseRepository.Instance<Player>().Start();  

    var solr = ServiceLocator.Current.GetInstance<ISolrOperations<Player>>();  
    var players = new PlayerRepository().GetPlayers();  

    **solr.Add(players);** // The remote server returned an error: (400) Bad Request.   
    solr.Commit();  
}  
like image 695
Benny Avatar asked Jan 06 '11 06:01

Benny


People also ask

Why do I get a 400 Bad Request error?

The HyperText Transfer Protocol (HTTP) 400 Bad Request response status code indicates that the server cannot or will not process the request due to something that is perceived to be a client error (for example, malformed request syntax, invalid request message framing, or deceptive request routing).

Why do I keep getting 400 Bad Request on Chrome?

What causes bad request errors on Chrome? Error 400 is a client error that occurs due to incorrect requests, invalid syntax, or routing issues. It can also occur if the URL is not recognized or you did not type it correctly. So, check again and make sure you typed the URL correctly.

How do I fix HTTP error 400 a request header field is too long?

Chosen solutionClear the Cache and remove the Cookies for websites that cause problems via the "3-bar" Firefox menu button (Options/Preferences). If clearing cookies didn't help then it is possible that the cookies. sqlite file in the Firefox profile folder that stores the cookies got corrupted. rename/remove cookies.


1 Answers

The solr log would give you the info that you need, or if you opened from console there should be an exception throw to the console.

like image 157
Jokin Avatar answered Sep 26 '22 23:09

Jokin