This is our custom component class, in which I want to get the data from one core and search data into another core and use facet query and show in descending order. means suppose we get t-shirt name from one core and same t-shirt name we will search it into another core and display the over all result with facet query
package com.shop.component;
import org.apache.solr.handler.component.ResponseBuilder;
import org.apache.solr.handler.component.SearchComponent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
public class CustomQueryComponent extends SearchComponent{
private static final Logger LOG = LoggerFactory.getLogger(CustomQueryComponent.class);
@Override
public void prepare(ResponseBuilder responseBuilder) throws IOException {
LOG.info("prepare method of CustomQueryComponent");
}
@Override
public void process(ResponseBuilder responseBuilder) throws IOException {
LOG.info("process method of CustomQueryComponent");
}
@Override
public String getDescription() {
return "CustomQueryComponent";
}
}
You can use the org.apache.solr.client.solrj.embedded.EmbeddedSolrServer in your own search component to fire off a Solr-query. In my example I am doing a call to the same core, so the only thing left is to figure out how it can be done to a different core: @Override public void prepare(final ResponseBuilder responseBuilder) throws IOException { SolrParams params = responseBuilder.req.getParams();
You can reach other collections running on the same solr-instance via the coreContainer on the req.getCore(), as I do in this example: