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

回答(16)

e15298c6a3b4591803e154ab0c3b3e2e.png

2 years ago

如果你想清理索尔索引 -

你可以开火http网址 -

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

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

*:*

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

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

e15298c6a3b4591803e154ab0c3b3e2e.png

2 years ago

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

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

http://host:port/solr/core/update?stream.body=*:*&commit=true

e15298c6a3b4591803e154ab0c3b3e2e.png

2 years ago

您可以使用以下命令删除 . 在delete by query命令中使用"match all docs"查询:

'*:*

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

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

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

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

http://localhost:8983/solr/update?stream.body=*:*

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

e15298c6a3b4591803e154ab0c3b3e2e.png

2 years ago

如果你想通过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);

}

}

如果要删除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);

}

}

e15298c6a3b4591803e154ab0c3b3e2e.png

2 years ago

发布json数据(例如卷曲)

curl -X POST -H 'Content-Type: application/json' \

'http://:/solr//update?commit=true' \

-d '{ "delete": {"query":"*:*"} }'

e15298c6a3b4591803e154ab0c3b3e2e.png

2 years ago

在delete by query命令中使用"match all docs"查询:

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

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

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

e15298c6a3b4591803e154ab0c3b3e2e.png

2 years ago

我来到这里寻找使用SolrNet从solr实例中删除所有文件到.Net框架 . 这是我能够做到的:

Startup.Init("http://localhost:8081/solr");

ISolrOperations solr =

ServiceLocator.Current.GetInstance>();

SolrQuery sq = new SolrQuery("*:*");

solr.Delete(sq);

solr.Commit();

这已经清除了所有文件 . (我不确定这是否可以恢复,我正处于Solr的学习和测试阶段,所以请在使用此代码之前考虑备份)

e15298c6a3b4591803e154ab0c3b3e2e.png

2 years ago

在浏览器中触发它

http://localhost:8983/solr/update?stream.body=*:*&commit=true 此命令将删除solr中索引中的所有文档

e15298c6a3b4591803e154ab0c3b3e2e.png

2 years ago

我用这个查询删除了所有记录 .

http://host/solr/core-name/update?stream.body=%3Cdelete%3E%3Cquery%3E*:*%3C/query%3E%3C/delete%3E&commit=true

e15298c6a3b4591803e154ab0c3b3e2e.png

2 years ago

如果您需要清理所有数据,重新创建集合可能会更快,例如

solrctl --zk localhost:2181/solr collection --delete

solrctl --zk localhost:2181/solr collection --create -s 1

e15298c6a3b4591803e154ab0c3b3e2e.png

2 years ago

当我从cygwin终端运行时,上面的卷曲示例都失败了 . 当我运行脚本示例时,有这样的错误 .

curl http://192.168.2.20:7773/solr/CORE1/update --data '*:*' -H 'Content-type:text/xml; charset=utf-8'

01

curl http://192.168.1.2:7773/solr/CORE1/update --data-binary '' -H 'Content-type:text/xml; charset=utf-8'

4002Unexpected EOF in prolog

at [row,col {unknown-source}]: [1,0]400

我需要在核心名称的循环中使用delete来将它们全部擦除到项目中 .

下面的查询在Cygwin终端脚本中为我工作 .

curl http://192.168.1.2:7773/hpi/CORE1/update?stream.body=*:*&commit=true

01

这一行使数据消失,变化持续存在 .

e15298c6a3b4591803e154ab0c3b3e2e.png

2 years ago

从命令行使用:

bin/post -c core_name -type text/xml -out yes -d $'*:*'

e15298c6a3b4591803e154ab0c3b3e2e.png

2 years ago

清除Solr索引时,还应该在运行delete-all查询后进行提交和优化 . 需要完整的步骤(curl就是你所需要的):http://www.alphadevx.com/a/365-Clearing-a-Solr-search-index

e15298c6a3b4591803e154ab0c3b3e2e.png

2 years ago

我创建了一个JavaScript书签,在Solr Admin UI中添加了删除链接

javascript: (function() {

var str, $a, new_href, href, upd_str = 'update?stream.body=*:*&commit=true';

$a = $('#result a#url');

href = $a.attr('href');

str = href.match('.+solr\/.+\/(.*)')[1];

new_href = href.replace(str, upd_str);

$('#result').prepend('DELETE ALL ' + new_href + '');

})();

ea32a5f5-98ae-4f93-a6cd-95c31fae21cc.png

e15298c6a3b4591803e154ab0c3b3e2e.png

2 years ago

如果你正在使用Cloudera 5.x,那么在本文档中提到Lily也保持实时更新和删除 .

由于HBase对HBase表格单元应用插入,更新和删除,因此索引器使用标准HBase复制使Solr与HBase表内容保持一致 .

不确定是否也支持 truncate 'hTable' .

否则,您可以创建一个触发器或服务来清除Solr和HBase上特定事件或任何事件的数据 .

e15298c6a3b4591803e154ab0c3b3e2e.png

2 years ago

Solr我不确定但您可以使用truncate命令从hbase删除所有数据,如下所示:

truncate 'table_name'

它将删除hbase表中的所有行键 .

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值