首页 文章

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

提问于
浏览
79

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

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

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

16 回答

  • 2

    如果你想清理索尔索引 -

    你可以开火http网址 -

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

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

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

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

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

  • 4

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

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

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

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

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

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

    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'
    

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

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

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

  • 90

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

    发布json数据(例如卷曲)

    curl -X POST -H 'Content-Type: application/json' \
        'http://<host>:<port>/solr/<core>/update?commit=true' \
        -d '{ "delete": {"query":"*:*"} }'
    
  • 8

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

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

    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'
    
  • 0

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

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

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

  • 0

    在浏览器中触发它

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

  • 6

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

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

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

    solrctl --zk localhost:2181/solr collection --delete <collectionName>
    solrctl --zk localhost:2181/solr collection --create <collectionName> -s 1
    
  • 3

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

    curl http://192.168.2.20:7773/solr/CORE1/update --data '<delete><query>*:*</query></delete>' -H 'Content-type:text/xml; charset=utf-8'
    <?xml version="1.0" encoding="UTF-8"?>
    <response>
    <lst name="responseHeader"><int name="status">0</int><int name="QTime">1</int></lst>
    </response>
    <!-- 
         It looks like it deleted stuff, but it did not go away
         maybe because the committing call failed like so 
    -->
    curl http://192.168.1.2:7773/solr/CORE1/update --data-binary '' -H 'Content-type:text/xml; charset=utf-8'
    <?xml version="1.0" encoding="UTF-8"?>
    <response>
    <lst name="responseHeader"><int name="status">400</int><int name="QTime">2</int></lst><lst name="error"><str name="msg">Unexpected EOF in prolog
     at [row,col {unknown-source}]: [1,0]</str><int name="code">400</int></lst>
    </response>
    

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

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

    curl http://192.168.1.2:7773/hpi/CORE1/update?stream.body=<delete><query>*:*</query></delete>&commit=true
    <?xml version="1.0" encoding="UTF-8"?>
    <response>
    <lst name="responseHeader"><int name="status">0</int><int name="QTime">1</int></lst>
    </response>
    

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

  • 1

    从命令行使用:

    bin/post -c core_name -type text/xml -out yes -d $'<delete><query>*:*</query></delete>'
    
  • 7

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

  • 1

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

    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>');
    })();
    

    enter image description here

  • 3

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

    Configuring the Lily HBase NRT Indexer Service for Use with Cloudera Search

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

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

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

  • 0

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

    truncate 'table_name'
    

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

相关问题