Solr是一个高性能,采用Java5开发,Solr基于Lucene的全文搜索服务器。
SolrJ是Apache提供的solr服务客服端工具
<dependency>
<groupId>org.apache.solr</groupId>
<artifactId>solr-solrj</artifactId>
</dependency>
使用httpSolrClient链接solr服务器
SolrClient client = new HttpSolrClient(solrServerUrl);
使用SolrQuery封装查询语句
SolrQuery parameters = new SolrQuery();
使用QueryResponse处理返回结果
QueryResponse response = client.query(parameters);
solr服务器使用xml文件存储索引
SolrDocumentList list = response.getResults();
使用SolrInputDocument对象更新索引
SolrInputDocument doc=new SolrInputDocument();
UpdateResponse response = client.add(doc);
solr服务端配置
schema.xml位于solr/conf/目录下,类似于数据表配置文件,用于定义字段类型