You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Ranveer Kumar <ra...@gmail.com> on 2010/02/07 17:24:20 UTC

Embedded Solr problem

Hi All,

I am still very new to solr.
Currently I am facing problem to use EmbeddedSolrServer.
following is my code:

                File home = new
File("D:/ranveer/java/solr_home/solr/first");
CoreContainer coreContainer = new CoreContainer();
SolrConfig config = null;
config = new SolrConfig(home + "/core1","solrconfig.xml",null);
CoreDescriptor descriptor = new CoreDescriptor(coreContainer,"core1",home +
"/core1");
SolrCore core = new SolrCore("core1", home+"/core1/data", config, new
IndexSchema(config, "schema.xml",null), descriptor);
coreContainer.register(core.getName(), core, true);
final EmbeddedSolrServer server = new EmbeddedSolrServer(coreContainer,
"core1");

Now my problem is every time when I making request for search SolrCore is
initializing the core.
I want if the core/instance of core is already start then just use
previously started core.
Due to this problem right now searching is taking too much time.
I tried to close core after search but same thing when fresh search result
is made, solr is starting from very basic.

please help..
thanks

Re: Embedded Solr problem

Posted by Sven Maurmann <sv...@kippdata.de>.
Hi Ranveer,

I assume that you have enough knowlesge in Java. You should essentially
your code for instantiating the server (depending on what you intend to
do this may be done in a separate class or in a method of the class doing
the queries). Then you use this instance to handle all the queries using
for example the method "query" of SolrServer.

For further information you may want to consult either the API documentation
or the url http://wiki.apache.org/solr/Solrj from the wiki.

Cheers,
    Sven

--On Montag, 8. Februar 2010 08:53 +0530 Ranveer Kumar 
<ra...@gmail.com> wrote:

> Hi Sven,
> thanks for reply.
>
> yes i notice that every time when request, new instance is created of solr
> server.
> could you please guide me to do the same ( initialization to create an
> instance of SolrServer, once during first request).
>
>
> On Mon, Feb 8, 2010 at 2:11 AM, Sven Maurmann
> <sv...@kippdata.de>wrote:
>
>> Hi,
>>
>> would it be possible that you instantiate a new instance of your
>> SolrServer every time you do a query?
>>
>> You should use the code you quoted in your mail once during
>> initialization to create an instance of SolrServer (the interface being
>> implemented by EmbeddedSolrServer) and subsquently use the query method
>> of SolrServer to do the query.
>>
>> Cheers,
>>    Sven
>>
>>
>> --On Sonntag, 7. Februar 2010 21:54 +0530 Ranveer Kumar <
>> ranveer.solr@gmail.com> wrote:
>>
>>  Hi All,
>>>
>>> I am still very new to solr.
>>> Currently I am facing problem to use EmbeddedSolrServer.
>>> following is my code:
>>>
>>>                File home = new
>>> File("D:/ranveer/java/solr_home/solr/first");
>>> CoreContainer coreContainer = new CoreContainer();
>>> SolrConfig config = null;
>>> config = new SolrConfig(home + "/core1","solrconfig.xml",null);
>>> CoreDescriptor descriptor = new
>>> CoreDescriptor(coreContainer,"core1",home + "/core1");
>>> SolrCore core = new SolrCore("core1", home+"/core1/data", config, new
>>> IndexSchema(config, "schema.xml",null), descriptor);
>>> coreContainer.register(core.getName(), core, true);
>>> final EmbeddedSolrServer server = new EmbeddedSolrServer(coreContainer,
>>> "core1");
>>>
>>> Now my problem is every time when I making request for search SolrCore
>>> is initializing the core.
>>> I want if the core/instance of core is already start then just use
>>> previously started core.
>>> Due to this problem right now searching is taking too much time.
>>> I tried to close core after search but same thing when fresh search
>>> result is made, solr is starting from very basic.
>>>
>>> please help..
>>> thanks
>>>
>> 

Re: Embedded Solr problem

Posted by Ranveer Kumar <ra...@gmail.com>.
Hi Sven,
thanks for reply.

yes i notice that every time when request, new instance is created of solr
server.
could you please guide me to do the same ( initialization to create an
instance of SolrServer, once during first request).


On Mon, Feb 8, 2010 at 2:11 AM, Sven Maurmann <sv...@kippdata.de>wrote:

> Hi,
>
> would it be possible that you instantiate a new instance of your SolrServer
> every time you do a query?
>
> You should use the code you quoted in your mail once during initialization
> to create an instance of SolrServer (the interface being implemented by
> EmbeddedSolrServer) and subsquently use the query method of SolrServer to
> do the query.
>
> Cheers,
>    Sven
>
>
> --On Sonntag, 7. Februar 2010 21:54 +0530 Ranveer Kumar <
> ranveer.solr@gmail.com> wrote:
>
>  Hi All,
>>
>> I am still very new to solr.
>> Currently I am facing problem to use EmbeddedSolrServer.
>> following is my code:
>>
>>                File home = new
>> File("D:/ranveer/java/solr_home/solr/first");
>> CoreContainer coreContainer = new CoreContainer();
>> SolrConfig config = null;
>> config = new SolrConfig(home + "/core1","solrconfig.xml",null);
>> CoreDescriptor descriptor = new CoreDescriptor(coreContainer,"core1",home
>> + "/core1");
>> SolrCore core = new SolrCore("core1", home+"/core1/data", config, new
>> IndexSchema(config, "schema.xml",null), descriptor);
>> coreContainer.register(core.getName(), core, true);
>> final EmbeddedSolrServer server = new EmbeddedSolrServer(coreContainer,
>> "core1");
>>
>> Now my problem is every time when I making request for search SolrCore is
>> initializing the core.
>> I want if the core/instance of core is already start then just use
>> previously started core.
>> Due to this problem right now searching is taking too much time.
>> I tried to close core after search but same thing when fresh search result
>> is made, solr is starting from very basic.
>>
>> please help..
>> thanks
>>
>

Re: Embedded Solr problem

Posted by Sven Maurmann <sv...@kippdata.de>.
Hi,

would it be possible that you instantiate a new instance of your SolrServer
every time you do a query?

You should use the code you quoted in your mail once during initialization
to create an instance of SolrServer (the interface being implemented by
EmbeddedSolrServer) and subsquently use the query method of SolrServer to
do the query.

Cheers,
     Sven

--On Sonntag, 7. Februar 2010 21:54 +0530 Ranveer Kumar 
<ra...@gmail.com> wrote:

> Hi All,
>
> I am still very new to solr.
> Currently I am facing problem to use EmbeddedSolrServer.
> following is my code:
>
>                 File home = new
> File("D:/ranveer/java/solr_home/solr/first");
> CoreContainer coreContainer = new CoreContainer();
> SolrConfig config = null;
> config = new SolrConfig(home + "/core1","solrconfig.xml",null);
> CoreDescriptor descriptor = new CoreDescriptor(coreContainer,"core1",home
> + "/core1");
> SolrCore core = new SolrCore("core1", home+"/core1/data", config, new
> IndexSchema(config, "schema.xml",null), descriptor);
> coreContainer.register(core.getName(), core, true);
> final EmbeddedSolrServer server = new EmbeddedSolrServer(coreContainer,
> "core1");
>
> Now my problem is every time when I making request for search SolrCore is
> initializing the core.
> I want if the core/instance of core is already start then just use
> previously started core.
> Due to this problem right now searching is taking too much time.
> I tried to close core after search but same thing when fresh search result
> is made, solr is starting from very basic.
>
> please help..
> thanks