HttpSolrClient client = new HttpSolrClient.Builder(solrUrl).withConnectionTimeout(10000).withSocketTimeout(60000).build();\r
\r
try {\r
+ String collection = "mediacube";\r
//add\r
- final SolrInputDocument doc = new SolrInputDocument();\r
- doc.addField("id", 2);\r
- doc.addField("name", "Name1");\r
- doc.addField("description", "Amazon Kindle Paperwhite");\r
+ SolrInputDocument doc = new SolrInputDocument();\r
+ doc.addField("id", 4);\r
+ doc.addField("name", "Fuck You");\r
+ UpdateResponse updateResponse = client.add(collection, doc);\r
+\r
+ doc = new SolrInputDocument();\r
+ doc.addField("id", 5);\r
+ doc.addField("name", "450 ezer forintos büntetésre ítélték a mentőautókon végiggyalogló turistákat");\r
+ updateResponse = client.add(collection, doc);\r
\r
- String collection = "mediacube";\r
- final UpdateResponse updateResponse = client.add(collection, doc);\r
client.commit(collection);\r
\r
//query\r
System.out.println("Found " + documents.getNumFound() + " documents");\r
for (SolrDocument document : documents) {\r
final String id = (String) document.getFirstValue("id");\r
- final String name = (String) document.getFirstValue("description");\r
+ final String name = (String) document.getFirstValue("name");\r
\r
- System.out.println("id: " + id + "; description: " + name);\r
+ System.out.println("id: " + id + "; name: " + name);\r
}\r
} catch (Exception e) {\r
System.out.println(e.getMessage());\r