1:添加
2查詢
3:刪除:
刪除兩種方法:
1、根據id刪除:
<delete>
<id>test001</id>
</delete>
<commit/>
2、根據查詢刪除:
<delete>
<query>*:*</query>
</delete>
<commit/>
二使用java代碼:實現功能
@Test public void addDoc() throws SolrServerException, IOException{ //創建一個連接 //單機版 SolrServer solrServer=new HttpSolrServer("http://192.168.100.91:8080/solr"); //集群版 //SolrServer solrServer2=new CloudSolrServer(""); //創建一個文檔對象 SolrInputDocument document=new SolrInputDocument(); document.addField("id", "test001"); document.addField("item_title", "測試商品"); //把文檔寫入索引庫 solrServer.add(document); //提交 solrServer.commit(); } @Test public void delDoc() throws SolrServerException, IOException{ //創建一個連接 SolrServer solrServer=new HttpSolrServer("http://192.168.100.91:8080/solr"); solrServer.deleteById("test001"); //提交 solrServer.commit(); }