QBoard » Big Data » Big Data - Data Storage : Hive, HBase, MongoDB, Teradata.. » How to delete all data from solr and HBase?

How to delete all data from solr and HBase?

  • 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

      October 9, 2020 11:18 AM IST
    0
  • 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 :

    http://host:port/solr/core/update?stream.body=<delete><query>*:*</query></delete>&commit=true
     
      October 10, 2020 11:25 AM IST
    1
  • 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":"*:*"} }'
     
      October 10, 2020 11:31 AM IST
    1
  • I tried the below steps. It works well.

    • Please make sure the SOLR server it running
    • Just click the link Delete all SOLR data which will hit and delete all your SOLR indexed datas then you will get the following details on the screen as output.


    <response>
      <lst name="responseHeader">
        <int name="status">0</int>
        <int name="QTime">494</int>
      </lst>
    </response>​

     

    • if you are not getting the above output then please make sure the following.

      • I used the default host (localhost) and port (8080) on the above link. please alter the host and port if it is different in your end.
      • The default core name should be collection / collection1. I used collection1 in the above link. please change it too if your core name is different.
      February 11, 2022 12:42 PM IST
    0
  • If you want to clean up Solr index -

    you can fire http url -

    http://host:port/solr/[core name]/update?stream.body=<delete><query>*:*</query></delete>&commit=true

    (replace [core name] with the name of the core you want to delete from). Or use this if posting data xml data:

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

    Be sure you use commit=true to commit the changes

    Don't have much idea with clearing hbase data though.

      October 10, 2020 11:23 AM IST
    0
  • 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);
        }
     }
      October 10, 2020 11:36 AM IST
    0