Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Use Solj with Cloudera Search

Use Solj with Cloudera Search

Contributor

Is it possible to use Solrj with Cloudera Search.  Are there any sample Java code that shows how to setup Solrj to connect to Cloudera Search running on CDH 5.10 cluster, and then perform query against indexed resources.

 

Any example or a pointer to one is appreciated.

1 REPLY 1
Highlighted

Re: Use Solj with Cloudera Search

Super Collaborator

The important piece of connecting to Cloudera search is to use the CloudSolrServer method as noted here: https://wiki.apache.org/solr/Solrj#Using_with_SolrCloud

 

 

The important piece of connecting to Cloudera search is to use the CloudSolrServer method as noted here:
https://wiki.apache.org/solr/Solrj#Using_with_SolrCloud

 

 

import org.apache.solr.client.solrj.impl.CloudSolrServer;
import org.apache.solr.common.SolrInputDocument;
CloudSolrServer server = new CloudSolrServer("localhost:9983");
server.setDefaultCollection("collection1");
SolrInputDocument doc = new SolrInputDocument();
doc.addField( "id", "1234");
doc.addField( "name", "A lovely summer holiday");
server.add(doc);
server.commit();

 

 

 

-pd