import org.apache.solr.client.solrj.SolrClient; import org.apache.solr.client.solrj.SolrServerException; import org.apache.solr.client.solrj.impl.HttpSolrClient; import org.apache.solr.common.SolrInputDocument; import java.io.IOException; public class SolrJExample { public static void main(String[] args) throws SolrServerException, IOException { String solrUrl = "http://localhost:8983/solr/your_core_name"; SolrClient solrClient = new HttpSolrClient.Builder(solrUrl).build(); SolrInputDocument document = new SolrInputDocument(); document.addField("field1", "value1"); document.addField("field2", "value2"); solrClient.add(document); solrClient.commit(); } }
I am a programmer but I hate grammar. Here you will find what I did, doing , will do ... Scattered pieces of knowledge that I have deleted from my mind to the trash bin through out my boring daily coding life. I will also report some of my failures in life so dear to me not success, because I have always learnt much only when I fail.
Wednesday, February 1, 2023
how to create a solr document with autogenerated unique id ?
how to create a solr document with autogenerated unique id ?
You can create a Solr document with an auto-generated unique ID by not specifying the ID field (i.e., id) when adding the document to Solr. If you do not specify an ID, Solr will automatically generate a unique ID for the document.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment