Solr学习笔记四--solrj的使用(更新文档)
来源:互联网 发布:英剧推荐知乎 编辑:程序博客网 时间:2024/05/24 00:14
在eclipse中通过solrj进行solr索引,要注意:
1,版本问题
2,包
自己测试了一个更新文档程序,可用
源代码:
package solrtest;import java.io.IOException;import java.net.MalformedURLException;import org.apache.solr.client.solrj.SolrServer;import org.apache.solr.client.solrj.SolrServerException;import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer;import org.apache.solr.client.solrj.request.UpdateRequest;import org.apache.solr.client.solrj.response.UpdateResponse;import org.apache.solr.common.SolrInputDocument;public class test { public static SolrServer getSolrServer() throws MalformedURLException{ //the instance can be reused return new CommonsHttpSolrServer("http://localhost:8983/solr/"); } public static void main(String[] args) throws SolrServerException, IOException {// TODO Auto-generated method stubSolrServer server = getSolrServer();SolrInputDocument document=new SolrInputDocument();document.addField("id", "lskyne");document.addField("title", "welcome to solr");server.add(document);server.commit();//UpdateRequest req =new UpdateRequest();//req.setAction(UpdateRequest.ACTION.COMMIT, false, false);//req.add(document);//UpdateResponse rsp =req.process(server);}}
结果:
进入http://localhost:8983/solr/admin/页面,输入查询条件:id:lskyne
<response><lst name="responseHeader"><int name="status">0</int><int name="QTime">1</int><lst name="params"><str name="indent">on</str><str name="start">0</str><str name="q">id:uid</str><str name="version">2.2</str><str name="rows">10</str></lst></lst><result name="response" numFound="1" start="0"><doc><str name="id">uid</str><arr name="title"><str>华中科技大学</str></arr></doc></result></response>
- Solr学习笔记四--solrj的使用(更新文档)
- Solr学习笔记五--solrj的使用(查询文档)
- Solr文档学习--Solrj的使用
- solr学习笔记 -- day05 solrJ的使用
- solr学习笔记 -- day03 使用solrJ客户端
- solr学习笔记(3)--使用solrj调用solr服务
- Solr solrj的使用
- solr-solrj的使用
- 【Apache Solr系列之四】Solr客户端SolrJ API使用文档-查询实例
- 搜索学习--Solr全文搜索服务器的基本使用(一)——SolrJ的使用
- Solr学习笔记三--更新文档搜索
- Solr(四)——Java使用solrj管理solr集群
- Solr笔记四之Solrj创建索引和搜索的一般步骤
- Solr笔记四之Solrj创建索引和搜索的一般步骤
- solr cloud系列-solrj的使用
- Solr JAVA客户端SolrJ的使用
- Solr-6.5.1之Solrj的使用
- solr 7.1.0中solrJ的使用
- 比较好的资料共享
- HDU 1088 (模拟)使用<sstream>模版库
- sql高效率分页
- 代理模式
- ORACLE备份恢复
- Solr学习笔记四--solrj的使用(更新文档)
- Java中switch语句
- hdu1088
- ssh login without passwd
- 可以直接拿来用的15个jQuery代码片段
- tree命令自动生成目录树
- HDU 2138 How many prime numbers(米勒拉宾素数测试算法)
- .net将Excel格式的xml导入到数据库
- block session