将索引从 Solr 导出到文件,字段对于 FieldCache 是非法的

Exporting index from Solr to a file, with fields illegal for FieldCache

我正在尝试将 Solr 索引导出到 JSON 文件。然而,在我关心的2个字段中,其中一个(字段A)是multivalued,另一个(字段Bneither indexed nor has doc values(这个字段可能缺少架构) .两者都会导致错误 can not use FieldCache on a field which is ...

这些字段的架构在远程服务器上,不应更改。无论如何都可以导出包含这些字段的索引吗?谢谢!

p.s。如果可能的话,我还想 fl 这两个字段,因为它们都是我所需要的。

在那种情况下,您可能想自己编写导出脚本,using a cursor mark 以加快检索速度(要使用 /export 功能,字段 has 有文档值已启用)。

有几种语言的示例可以在光标标记页面上获取所有文档,它们几乎可以直接应用(您必须自己添加 JSON 编写)到您的结果集中。

SolrQuery q = (new SolrQuery(some_query)).setRows(r).setSort(SortClause.asc("id"));
String cursorMark = CursorMarkParams.CURSOR_MARK_START;
boolean done = false;
while (! done) {
  q.set(CursorMarkParams.CURSOR_MARK_PARAM, cursorMark);
  QueryResponse rsp = solrServer.query(q);
  String nextCursorMark = rsp.getNextCursorMark();
  doCustomProcessingOfResults(rsp);
  if (cursorMark.equals(nextCursorMark)) {
    done = true;
  }
  cursorMark = nextCursorMark;
}

确保使用相当大的 r 值以减少往返次数。