如何从solr和hbase中删除所有数据

XMe*_*Men 93 solr hbase

如何从solr命令中删除所有数据?我们正在使用solrlilyhbase.

如何从hbase和solr中删除数据?

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

Jay*_*dra 178

如果你想清理索尔索引 -

你可以解雇http url -

http://host:port/solr/[core name]/update?stream.body=<delete><query>*:*</query></delete>&commit=true
Run Code Online (Sandbox Code Playgroud)

(替换[core name]为要从中删除的核心的名称).或者如果发布数据xml数据,请使用此方法:

<delete><query>*:*</query></delete>
Run Code Online (Sandbox Code Playgroud)

请务必使用commit=true提交更改

但是,清除hbase数据并不是很清楚.

  • 如果您使用多核设置,则需要核心. (7认同)
  • 您可能希望将`&commit = true`添加到查询中,使其变为`http:// host:port/solr/core/update?stream.body = <delete> <query>*:*</ query> </删除>&commit = true`没有它我想知道为什么没有删除所有文件. (6认同)
  • 没用 我得到:HTTP错误404访问/ solr / update时出现问题。原因:找不到从... (2认同)

小智 90

我已经使用此请求删除了所有记录,但有时需要提交此记录.

为此,请添加&commit=true到您的请求中:

http://host:port/solr/core/update?stream.body=<delete><query>*:*</query></delete>&commit=true
Run Code Online (Sandbox Code Playgroud)


Nav*_*Nav 11

您可以使用以下命令进行删除.在delete by query命令中使用"匹配所有文档"查询:

'<delete><query>*:*</query></delete>
Run Code Online (Sandbox Code Playgroud)

您还必须在运行删除后提交,以清空索引,运行以下两个命令:

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'
Run Code Online (Sandbox Code Playgroud)

另一种策略是在浏览器中添加两个书签:

http://localhost:8983/solr/update?stream.body=<delete><query>*:*</query></delete>
http://localhost:8983/solr/update?stream.body=<commit/>
Run Code Online (Sandbox Code Playgroud)


来自SOLR的源文档:https:
//wiki.apache.org/solr/FAQ#How_can_I_delete_all_documents_from_my_index.3F


RAT*_*ora 8

如果你想通过SolrJ删除Solr中的所有数据,请执行以下操作.

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);
    }
}
Run Code Online (Sandbox Code Playgroud)

如果你想删除HBase中的所有数据,请执行以下操作.

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);
    }
 }
Run Code Online (Sandbox Code Playgroud)


Fra*_* R. 8

发布json数据(例如卷曲)

curl -X POST -H 'Content-Type: application/json' \
    'http://<host>:<port>/solr/<core>/update?commit=true' \
    -d '{ "delete": {"query":"*:*"} }'
Run Code Online (Sandbox Code Playgroud)


Nan*_*mar 5

在按查询删除命令中使用“匹配所有文档”查询

您还必须在运行删除后提交,以便清空索引,运行以下两个命令:

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'
Run Code Online (Sandbox Code Playgroud)