Hello,

I use below code snippet to index data from a text file into solr. My text data 
is a tsv file with 3 fields - id,title and types. The field "types" is a 
multivalued field and these values are available as comma separated in the text 
file itself.
Here is an example: 123 building house,skyscraper,hut

id is 123 title is building types is house,skyscraper,hut

How do I modify my code to store types as a multivalued field in Solr?

  HttpSolrServer server = new HttpSolrServer("/my/solr/home");

  ModifiableSolrParams solrparams = new ModifiableSolrParams(new 
ModifiableSolrParams());

  solrparams.set("fieldnames", "id,title,types");

  ContentStreamUpdateRequest request = new 
ContentStreamUpdateRequest("/update");

  request.setParams(params);

  ContentStream readFile = new ContentStreamBase.FileStream(new 
File("myFile.txt"));

  request.addContentStream(readFile);

  SolrResponseBase response = null;

  try {

    response = (SolrResponseBase) request.process(server);

  }catch(Exception e){

      e.printStackTrace();

  }


Regards,
Ashish

**************** CAUTION - Disclaimer *****************
This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely
for the use of the addressee(s). If you are not the intended recipient, please
notify the sender by e-mail and delete the original message. Further, you are 
not
to copy, disclose, or distribute this e-mail or its contents to any other 
person and
any such actions are unlawful. This e-mail may contain viruses. Infosys has 
taken
every reasonable precaution to minimize this risk, but is not liable for any 
damage
you may sustain as a result of any virus in this e-mail. You should carry out 
your
own virus checks before opening the e-mail or attachment. Infosys reserves the
right to monitor and review the content of all messages sent to or from this 
e-mail
address. Messages sent to or from this e-mail address may be stored on the
Infosys e-mail system.
***INFOSYS******** End of Disclaimer ********INFOSYS***

Reply via email to