On 9/26/2013 5:33 AM, Darius Miliauskas wrote:
> Dear All,
>
> I am trying to use Solr (actually Solrj) to make a simple app which will
> give me the recommended texts according to the similarity to the history of
> reading other texts. Firstly, I need to input these texts to the server.
> Let's say I have 1000 .txt files in one folder or 1000 html articles
> online. How can I input these texts into server with Java? What words
> should I use instead of the question marks in .addField(? ?)? It would be
> awesome if somebody would give me any samples of code in Java.
Here's a very simplistic example of how to add documents with SolrJ.
The "server" variable is a SolrServer object that you must define.
Usually it will be either HttpSolrServer or CloudSolrServer.
Collection<SolrInputDocument> docs = new ArrayList<SolrInputDocument>();
SolrInputDocument doc = new SolrInputDocument();
doc.addField("fieldname", "fieldValue");
docs.add(doc);
server.add(docs);
Thanks,
Shawn