Out of the box, the simplest way to configure CommonsHttpSolrServer through a spring application context is to simply define the bean for the server and inject it into whatever class you have that will use it, like Avlesh shared below. <bean id="httpSolrServer" class="org.apache.solr.client.solrj.impl.CommonsHttpSolrServer" >
                <constructor-arg>
                        <value>http://localhost:8080/solr/core0</value>
                </constructor-arg>
        </bean>

You can also set the connection parameters like Avlesh did with the HttpClient in the context, or directly in the init method of your implementation.
Inject it with a property:
        <property name="solrServer">
                <ref bean="httpSolrServer" />
        </property>

A bit more tricky with the embedded solr server since you need to also register cores etc. We solved that by creating a core configuration loader class.

- Aleks


On Sat, 09 May 2009 03:08:25 +0200, Avlesh Singh <avl...@gmail.com> wrote:

I am giving you a detailed sample of my spring usage.

<bean id="solrHttpClient" class="org.apache.commons.httpclient.HttpClient">
    <property name="httpConnectionManager">
        <bean
class="org.apache.commons.httpclient.MultiThreadedHttpConnectionManager">
            <property name="maxConnectionsPerHost" value="10"/>
            <property name="maxTotalConnections" value="10"/>
        </bean>
    </property>
</bean>

<bean id="mySearchImpl" class="com.me.search.MySearchSolrImpl">
    <property name="core1">
        <bean
class="org.apache.solr.client.solrj.impl.CommonsHttpSolrServer">
            <constructor-arg value="http://localhost/solr/core1"/>
            <constructor-arg ref="solrHttpClient"/>
        </bean>
    </property>
    <property name="core2">
        <bean
class="org.apache.solr.client.solrj.impl.CommonsHttpSolrServer">
            <constructor-arg value="http://localhost/solr/core2"/>
            <constructor-arg ref="solrHttpClient"/>
        </bean>
    </property>
</bean>

Hope this helps.

Cheers
Avlesh

On Sat, May 9, 2009 at 12:39 AM, sachin78 <tendulkarsachi...@gmail.com>wrote:


Ranjeeth,

Did you figured aout how to do this? If yes, can you share with me how
you did it? Example bean definition in xml will be helpful.

--Sachin


Funtick wrote:
>
> Use constructor and pass URL parameter. Nothing SPRING related...
>
> Create a Spring bean with attributes 'MySolr', 'MySolrUrl', and 'init'
> method... 'init' will create instance of CommonsHttpSolrServer. Configure
> Spring...
>
>
>
>> I am using Solr 1.3 and Solrj as a Java Client. I am
>> Integarating Solrj in Spring framwork, I am facing a problem,
>> Spring framework is not inializing CommonsHttpSolrServer
>> class, how can  I define this class to get the instance of
>> SolrServer to invoke furthur method on this.
>>
>
>
>

--
View this message in context:
http://www.nabble.com/Initialising-of-CommonsHttpSolrServer-in-Spring-framwork-tp18808743p23451795.html
Sent from the Solr - User mailing list archive at Nabble.com.





--
Aleksander M. Stensby
Lead software developer and system architect
Integrasco A/S
www.integrasco.no
http://twitter.com/Integrasco

Please consider the environment before printing all or any of this e-mail

Reply via email to