6

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();  
}  
George Stocker
  • 57,289
  • 29
  • 176
  • 237
Benny
  • 61
  • 1
  • 1
  • 3
  • new SolrBaseRepository.Instance().Start(); var solr = ServiceLocator.Current.GetInstance>(); var specificPlayer = new PlayerRepository().GetPlayer(player.FirstName, player.LastName, player.Position); solr.Add(specificPlayer); solr.Commit(); – Benny Jan 06 '11 at 06:29
  • please post the code in the question, properly formatted. Also post the definition of SolrBaseRepository. – Mauricio Scheffer Jan 06 '11 at 06:44
  • also post the definition of Player and your schema.xml. – Mauricio Scheffer Jan 06 '11 at 06:44

3 Answers3

5

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.

Jokin
  • 4,188
  • 2
  • 31
  • 30
3

Look at Tomcat log file, it contains detailed Solr exception. On my machine it's located at

C:\Program Files\Apache Software Foundation\Tomcat 7.0\logs

You'll find a file named in the format catalina..log. (e.g. catalina.2011-05-26.log)

CleanCoder
  • 807
  • 1
  • 9
  • 19
1

Here's what you can do:

  • Comment all /dataimport blocks in solrconfig.xml
  • Make sure ProtocolVersion is HttpVersion.Version10 (the Post method in SolrNet.Impl.SolrConnection). If not, download the SolrNet source and re-compile with your preference.
Martin S Ek
  • 2,043
  • 2
  • 16
  • 22
  • Did you experience any problem that motivated you to switch to HttpVersion.Version10 ? I'd like to hear about that. – Mauricio Scheffer Jan 16 '11 at 23:15
  • 1
    I read that switching to HttpVersion.Version10 would help. I think what helped me tho, was checking that the solrconfig.xml was well-formed. – Martin S Ek Jan 17 '11 at 15:02