How to delete all data from solr and hbase

2019-03-07 13:11发布

How do I delete all data from solr by command? We are using solr with lily and hbase.

How can I delete data from both hbase and solr?

http://lucene.apache.org/solr/4_10_0/tutorial.html#Deleting+Data

标签: solr hbase
16条回答
对你真心纯属浪费
2楼-- · 2019-03-07 13:23

Post json data (e.g. with curl)

curl -X POST -H 'Content-Type: application/json' \
    'http://<host>:<port>/solr/<core>/update?commit=true' \
    -d '{ "delete": {"query":"*:*"} }'
查看更多
够拽才男人
3楼-- · 2019-03-07 13:23

I came here looking to delete all documents from solr instance through .Net framework using SolrNet. Here is how I was able to do it:

Startup.Init<MyEntity>("http://localhost:8081/solr");
ISolrOperations<MyEntity> solr =
    ServiceLocator.Current.GetInstance<ISolrOperations<MyEntity>>();
SolrQuery sq = new SolrQuery("*:*");
solr.Delete(sq);
solr.Commit();

This has cleared all the documents. (I am not sure if this could be recovered, I am in learning and testing phase of Solr, so please consider backup before using this code)

查看更多
4楼-- · 2019-03-07 13:27

You can use the following commands to delete. Use the "match all docs" query in a delete by query command:

'<delete><query>*:*</query></delete>

You must also commit after running the delete so, to empty the index, run the following two commands:

curl http://localhost:8983/solr/update --data '<delete><query>*:*</query></delete>' -H 'Content-type:text/xml; charset=utf-8'
curl http://localhost:8983/solr/update --data '<commit/>' -H 'Content-type:text/xml; charset=utf-8'

Another strategy would be to add two bookmarks in your browser:

http://localhost:8983/solr/update?stream.body=<delete><query>*:*</query></delete>
http://localhost:8983/solr/update?stream.body=<commit/>


Source docs from SOLR:
https://wiki.apache.org/solr/FAQ#How_can_I_delete_all_documents_from_my_index.3F

查看更多
贼婆χ
5楼-- · 2019-03-07 13:27

If you need to clean out all data, it might be faster to recreate collection, e.g.

solrctl --zk localhost:2181/solr collection --delete <collectionName>
solrctl --zk localhost:2181/solr collection --create <collectionName> -s 1
查看更多
一纸荒年 Trace。
6楼-- · 2019-03-07 13:30

From the command line use:

 bin/post -c core_name -type text/xml -out yes -d $'<delete><query>*:*</query></delete>'
查看更多
虎瘦雄心在
7楼-- · 2019-03-07 13:32

Use the "match all docs" query in a delete by query command: :

You must also commit after running the delete so, to empty the index, run the following two commands:

curl http://localhost:8983/solr/update --data '<delete><query>*:*</query></delete>' -H 'Content-type:text/xml; charset=utf-8'

curl http://localhost:8983/solr/update --data '<commit/>' -H 'Content-type:text/xml; charset=utf-8'
查看更多
登录 后发表回答