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 Nicholas Ding <ni...@gmail.com> on 2012/11/27 01:18:37 UTC

Search among multiple cores

Hi,

I'm working on a search engine project based on Solr. Now I have three
cores (Core A, B, C). I need to search Core A and Core B to get required
parameters to search Core C. So far, I wrote a SearchComponent which uses
SolrJ inside because I can't access other cores directly in
SearchComponent. I was bit worried about performance and scalability
because SolrJ brings little HTTP overhead.

After digging into the Solr's source code, I wrote a SolrContextListener to
initialize CoreContainer at server startup then put it into a
ServlerContext. Then I wrote another Servlet to get a reference from
ServletContext and now I'm able to get all the Core references in Java.

The good part is I can access all Solr's internal structure in Java, but
the bad part is I have to deal with internal types which requires deep
understanding of Solr's source code.

I was wondering if anybody had done similar things before? What's the side
effects of extending Solr in code level?

Thanks
Nicholas

Re: Search among multiple cores

Posted by Nicholas Ding <ni...@gmail.com>.
Hi Otis,

Thank you so much, that's exactly what I need!

Thanks
Nicholas

On Mon, Nov 26, 2012 at 10:28 PM, Otis Gospodnetic <
otis.gospodnetic@gmail.com> wrote:

> Would http://wiki.apache.org/solr/Solrj#EmbeddedSolrServer save you some
> work?
>
> Otis
> --
> SOLR Performance Monitoring - http://sematext.com/spm/index.html
> Search Analytics - http://sematext.com/search-analytics/index.html
>
>
>
>
> On Mon, Nov 26, 2012 at 7:18 PM, Nicholas Ding <nicholasdsj@gmail.com
> >wrote:
>
> > Hi,
> >
> > I'm working on a search engine project based on Solr. Now I have three
> > cores (Core A, B, C). I need to search Core A and Core B to get required
> > parameters to search Core C. So far, I wrote a SearchComponent which uses
> > SolrJ inside because I can't access other cores directly in
> > SearchComponent. I was bit worried about performance and scalability
> > because SolrJ brings little HTTP overhead.
> >
> > After digging into the Solr's source code, I wrote a SolrContextListener
> to
> > initialize CoreContainer at server startup then put it into a
> > ServlerContext. Then I wrote another Servlet to get a reference from
> > ServletContext and now I'm able to get all the Core references in Java.
> >
> > The good part is I can access all Solr's internal structure in Java, but
> > the bad part is I have to deal with internal types which requires deep
> > understanding of Solr's source code.
> >
> > I was wondering if anybody had done similar things before? What's the
> side
> > effects of extending Solr in code level?
> >
> > Thanks
> > Nicholas
> >
>

Re: Search among multiple cores

Posted by Amit Nithian <an...@gmail.com>.
You can simplify your code by searching across cores in the SearchComponent:
1) public class YourComponent implements SolrCoreAware
--> Grab instance of CoreContainer and store (mCoreContainer =
core.getCoreDescriptor().getCoreContainer();)
2) In the process method:
* grab the core requested (SolrCore core
= mCoreContainer.getCore(sCoreName);)

This way you can avoid having to implement the listener you mentioned and
passing this in the servlet config.


On Mon, Nov 26, 2012 at 7:28 PM, Otis Gospodnetic <
otis.gospodnetic@gmail.com> wrote:

> Would http://wiki.apache.org/solr/Solrj#EmbeddedSolrServer save you some
> work?
>
> Otis
> --
> SOLR Performance Monitoring - http://sematext.com/spm/index.html
> Search Analytics - http://sematext.com/search-analytics/index.html
>
>
>
>
> On Mon, Nov 26, 2012 at 7:18 PM, Nicholas Ding <nicholasdsj@gmail.com
> >wrote:
>
> > Hi,
> >
> > I'm working on a search engine project based on Solr. Now I have three
> > cores (Core A, B, C). I need to search Core A and Core B to get required
> > parameters to search Core C. So far, I wrote a SearchComponent which uses
> > SolrJ inside because I can't access other cores directly in
> > SearchComponent. I was bit worried about performance and scalability
> > because SolrJ brings little HTTP overhead.
> >
> > After digging into the Solr's source code, I wrote a SolrContextListener
> to
> > initialize CoreContainer at server startup then put it into a
> > ServlerContext. Then I wrote another Servlet to get a reference from
> > ServletContext and now I'm able to get all the Core references in Java.
> >
> > The good part is I can access all Solr's internal structure in Java, but
> > the bad part is I have to deal with internal types which requires deep
> > understanding of Solr's source code.
> >
> > I was wondering if anybody had done similar things before? What's the
> side
> > effects of extending Solr in code level?
> >
> > Thanks
> > Nicholas
> >
>

Re: Search among multiple cores

Posted by Otis Gospodnetic <ot...@gmail.com>.
Would http://wiki.apache.org/solr/Solrj#EmbeddedSolrServer save you some
work?

Otis
--
SOLR Performance Monitoring - http://sematext.com/spm/index.html
Search Analytics - http://sematext.com/search-analytics/index.html




On Mon, Nov 26, 2012 at 7:18 PM, Nicholas Ding <ni...@gmail.com>wrote:

> Hi,
>
> I'm working on a search engine project based on Solr. Now I have three
> cores (Core A, B, C). I need to search Core A and Core B to get required
> parameters to search Core C. So far, I wrote a SearchComponent which uses
> SolrJ inside because I can't access other cores directly in
> SearchComponent. I was bit worried about performance and scalability
> because SolrJ brings little HTTP overhead.
>
> After digging into the Solr's source code, I wrote a SolrContextListener to
> initialize CoreContainer at server startup then put it into a
> ServlerContext. Then I wrote another Servlet to get a reference from
> ServletContext and now I'm able to get all the Core references in Java.
>
> The good part is I can access all Solr's internal structure in Java, but
> the bad part is I have to deal with internal types which requires deep
> understanding of Solr's source code.
>
> I was wondering if anybody had done similar things before? What's the side
> effects of extending Solr in code level?
>
> Thanks
> Nicholas
>