After solr4.6 is installed, I tried to import data to collection1 in batches using csv files.
First, write the csvfile (book.csv. My path is: E:/book.csv. And pay attention to the file encoding. My encoding is GB2312. It will be used for later uploads. If it is wrong, Chinese characters will be garbled.
Id; title; content
16. "New Year's Eve"; "a chairman is on stage and will not have a holiday on New Year's Eve. "
17. "Diaoyu Islands"; "Diaoyu Islands belong to China, while cangjingkong belongs to the world"
Then modify schema. xml. Clear all the defined fields in fields, but keep the "_ version _", and "_ root _" elements. The fields are defined as follows:
<Field name = "id" type = "string" stored = "true" indexed = "true"/>
<Field name = "title" type = "string" stored = "true" indexed = "true"/>
<Field name = "content" type = "string" stored = "true" indexed = "true"/>
You also need to modify solrconfig. xml.
Take the following section:
<RequestHandler name = "/update/csv" class = "solr. CSVRequestHandler">
<Lst name = "defaults">
<Str name = "stream. contentType"> application/csv </str>
</Lst>
</RequestHandler>
Replace:
<RequestHandler name = "/update/csv" class = "solr. CSVRequestHandler" startup = "lazy">
<Lst name = "defaults">
<Str name = "separator" >;</str>
<Str name = "header"> true </str>
<Str name = "encapsulator"> "</str>
</Lst>
</RequestHandler>
The separator field indicates that each field of data in each row is separated by a semicolon.
After all the modifications, restart tomcat. In windows, execute the following http request in the address bar of the browser:
Http: // localhost: 8080/solr/update/csv? Commit = true & stream. file = E:/book.csv & stream. contentType = text/plain;
Charset = GB2312
Note that commit = true must exist, otherwise data insertion will not succeed. E:/book.csv. This is the absolute path of the file .; Charset = GB2312: This is the file encoding method of my csv file. Make sure that this is clear; otherwise, Chinese characters are garbled.
After the execution, view the result:
Solr details: click here
Solr: click here
Solr3.6.1 build an environment in Tomcat6
Tomcat-based Solr3.5 cluster deployment
Load Balancing for Solr clusters using Nginx on Linux
Install and use Solr in Linux
Deploy Solr 4 on Ubuntu 12.04 LTS through Tomcat
Solr implements Low Level query parsing (QParser)
Build a search Server Based on Solr 3.5
Solr 3.5 development and application tutorial PDF
Solr 4.0 deployment instance tutorial