Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 262 Vote(s) - 3.42 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to delete all data from solr and hbase

#1
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?

[To see links please register here]

Reply

#2
I've used this request to delete all my records but sometimes it's necessary to commit this.

For that, add `&commit=true` to your request :

[To see links please register here]

:port/solr/core/update?stream.body=<delete><query>*:*</query></delete>&commit=true
Reply

#3
If you want to delete all of the data in Solr via SolrJ do something like this.

public static void deleteAllSolrData() {
HttpSolrServer solr = new HttpSolrServer("http://localhost:8080/solr/core/");
try {
solr.deleteByQuery("*:*");
} catch (SolrServerException e) {
throw new RuntimeException("Failed to delete data in Solr. "
+ e.getMessage(), e);
} catch (IOException e) {
throw new RuntimeException("Failed to delete data in Solr. "
+ e.getMessage(), e);
}
}

If you want to delete all of the data in HBase do something like this.

public static void deleteHBaseTable(String tableName, Configuration conf) {
HBaseAdmin admin = null;
try {
admin = new HBaseAdmin(conf);
admin.disableTable(tableName);
admin.deleteTable(tableName);
} catch (MasterNotRunningException e) {
throw new RuntimeException("Unable to delete the table " + tableName
+ ". The actual exception is: " + e.getMessage(), e);
} catch (ZooKeeperConnectionException e) {
throw new RuntimeException("Unable to delete the table " + tableName
+ ". The actual exception is: " + e.getMessage(), e);
} catch (IOException e) {
throw new RuntimeException("Unable to delete the table " + tableName
+ ". The actual exception is: " + e.getMessage(), e);
} finally {
close(admin);
}
}
Reply

#4
When clearing out a Solr index, you should also do a commit and optimize after running the delete-all query. Full steps required (curl is all you need):

[To see links please register here]

Reply

#5
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)*
Reply

#6
fire this in the browser

`http://localhost:8983/solr/update?stream.body=<delete><query>*:*</query></delete>&commit=true`
this commmand will delete all the documents in index in solr
Reply

#7
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
Reply

#8
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

[To see links please register here]

--data '<delete><query>*:*</query></delete>' -H 'Content-type:text/xml; charset=utf-8'

curl

[To see links please register here]

--data '<commit/>' -H 'Content-type:text/xml; charset=utf-8'
Reply

#9
I made a JavaScript bookmark which adds the delete link in Solr Admin UI

<!-- begin snippet: js hide: false -->

<!-- language: lang-js -->

javascript: (function() {
var str, $a, new_href, href, upd_str = 'update?stream.body=<delete><query>*:*</query></delete>&commit=true';
$a = $('#result a#url');
href = $a.attr('href');
str = href.match('.+solr\/.+\/(.*)')[1];
new_href = href.replace(str, upd_str);
$('#result').prepend('<a id="url_upd" class="address-bar" href="' + new_href + '"><strong>DELETE ALL</strong> ' + new_href + '</a>');
})();

<!-- end snippet -->

![enter image description here][1]


[1]:
Reply

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

'<delete><query>*:*</query></delete>
You must also commit after running the delete so, to empty the index, run the following two commands:<br>

curl

[To see links please register here]

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

[To see links please register here]

--data '<commit/>' -H 'Content-type:text/xml; charset=utf-8'
Another strategy would be to add two bookmarks in your browser:

[To see links please register here]

;

[To see links please register here]

;


<br>
Source docs from SOLR: <br>

[To see links please register here]

Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through