【solr操作】solr刪除數據的4種方便快捷的方式-【刪除】



1、在solr客戶端,訪問你的索引庫(我認爲最方便的方法)

1)documents type 選擇 XML 
2)documents 輸入下面語句
<delete><query>*:*</query></delete>

<commit/>

3)


點擊Submit Document 即可

2、solr-用url,使用 stream 相關參數刪除數據:

如:

根據id刪除數據

http://localhost:8080/solr/update/?stream.body=

<delete><id>id值</id></delete>&stream.contentType=text/xml;charset=utf-8&commit=true

根據查詢參數條件刪除數據

http://localhost:8080/solr/update/?stream.body=

<delete><query>參數</query></delete>&stream.contentType=text/xml;charset=utf-8&commit=true

stream 相關參數:

stream.file=(服務器本地文件);

stream.url 分別指到你的刪除文本,這裏是直接字符串內容用 stream.body 參數。

commit 參數是指提交,提交了才能看到刪除效果。

刪除指令有兩種,一是:用 <id></id> 包裝;二是:<query></query> 包裝。指令都很明顯,一個是 id 值(是在 schema.xml 的 uniqueKey 所指字段的值,而不是索引內部的 docId);query 值是查詢串,如:title:"solr lucene"。

3、curl 方式:

  1. curl  http://localhost:8080/update --data-binary  "<delete><query>title:abc</query></delete>"  -H 'Content- type :text/xml; charset=utf-8'  
  2.   
  3. #刪除完後,要提交   
  4.   
  5. curl  http://localhost:8080/update --data-binary  "<commit/>"  -H 'Content- type:text/xml; charset=utf-8'  

4、用自帶的 post.jar,在 apache-solr-XXX/example/exampledocs 目錄下:

  1. java -Ddata=args  -jar post.jar  "<delete><id>42</id></delete>"   
  2.   
  3. #怎麼使用 post.jar 查看幫助   
  4.   
  5. java -jar post.jar -help 


小結:

方式1就是直接可以告訴服務器從那些地方去刪除的數據內容;

方式2、3原理一樣,直接 POST xml 數據過去;

出處:http://blog.csdn.net/lbf5210/article/details/51207043

1、在solr客戶端,訪問你的索引庫(我認爲最方便的方法)

1)documents type 選擇 XML 
2)documents 輸入下面語句
<delete><query>*:*</query></delete>

<commit/>

3)


點擊Submit Document 即可

2、solr-用url,使用 stream 相關參數刪除數據:

如:

根據id刪除數據

http://localhost:8080/solr/update/?stream.body=

<delete><id>id值</id></delete>&stream.contentType=text/xml;charset=utf-8&commit=true

根據查詢參數條件刪除數據

http://localhost:8080/solr/update/?stream.body=

<delete><query>參數</query></delete>&stream.contentType=text/xml;charset=utf-8&commit=true

stream 相關參數:

stream.file=(服務器本地文件);

stream.url 分別指到你的刪除文本,這裏是直接字符串內容用 stream.body 參數。

commit 參數是指提交,提交了才能看到刪除效果。

刪除指令有兩種,一是:用 <id></id> 包裝;二是:<query></query> 包裝。指令都很明顯,一個是 id 值(是在 schema.xml 的 uniqueKey 所指字段的值,而不是索引內部的 docId);query 值是查詢串,如:title:"solr lucene"。

3、curl 方式:

  1. curl  http://localhost:8080/update --data-binary  "<delete><query>title:abc</query></delete>"  -H 'Content- type :text/xml; charset=utf-8'  
  2.   
  3. #刪除完後,要提交   
  4.   
  5. curl  http://localhost:8080/update --data-binary  "<commit/>"  -H 'Content- type:text/xml; charset=utf-8'  

4、用自帶的 post.jar,在 apache-solr-XXX/example/exampledocs 目錄下:

  1. java -Ddata=args  -jar post.jar  "<delete><id>42</id></delete>"   
  2.   
  3. #怎麼使用 post.jar 查看幫助   
  4.   
  5. java -jar post.jar -help 


小結:

方式1就是直接可以告訴服務器從那些地方去刪除的數據內容;

方式2、3原理一樣,直接 POST xml 數據過去;

出處:http://blog.csdn.net/lbf5210/article/details/51207043

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章