Solr7.4.0报错org.apache.solr.common.SolrException

文章目录

  • [org.apache.solr.common.SolrException: Exception writing document id MATERIAL-99598435990497269125316 to the index; possible analysis error: cannot change DocValues type from NUMERIC to SORTED_NUMERIC for field "opt_time"](#org.apache.solr.common.SolrException: Exception writing document id MATERIAL-99598435990497269125316 to the index; possible analysis error: cannot change DocValues type from NUMERIC to SORTED_NUMERIC for field "opt_time")
  • [Exception writing document id MATERIAL-43619171460367415133741 to the index; possible analysis error: cannot change DocValues type from NUMERIC to SORTED_NUMERIC for field "opt_time"](#Exception writing document id MATERIAL-43619171460367415133741 to the index; possible analysis error: cannot change DocValues type from NUMERIC to SORTED_NUMERIC for field "opt_time")

org.apache.solr.common.SolrException: Exception writing document id MATERIAL-99598435990497269125316 to the index; possible analysis error: cannot change DocValues type from NUMERIC to SORTED_NUMERIC for field "opt_time"

查看当前字段定义:

sh 复制代码
curl http://localhost:8983/solr/your_core/schema/fields/opt_time

请将 your_core 替换为你的Solr核心名称

删除旧字段定义:

sh 复制代码
curl -X DELETE http://localhost:8983/solr/your_core/schema/fields/opt_time

可以使用 web 页面删除

重新定义字段:

sh 复制代码
curl -X POST -H 'Content-type:application/json' --data-binary '{
  "add-field": {
    "name": "opt_time",
    "type": "pdate",
    "indexed": true,
    "stored": true,
    "docValues": true,
    "multiValued": false
  }
}' http://localhost:8983/solr/your_core/schema

Exception writing document id MATERIAL-43619171460367415133741 to the index; possible analysis error: cannot change DocValues type from NUMERIC to SORTED_NUMERIC for field "opt_time"

这个错误信息表明在使用 SolrJ 客户端向 Solr 服务器发送文档时遇到了问题。具体错误是尝试将字段 "opt_time" 的 DocValues 类型从 NUMERIC 更改为 SORTED_NUMERIC,这在 Solr 中是不允许的。

首先,你需要检查 Solr 的 managed-schema 或 schema.xml 文件中字段 "opt_time" 的定义。如果你使用的是 managed-schema,你可以通过 Solr 的管理界面或使用 Schema API 来查看字段定义。

更新字段定义

如果 "opt_time" 字段的 DocValues 类型确实需要是 SORTED_NUMERIC,而当前设置为 NUMERIC,你需要更新字段定义。这可以通过 Schema API 来完成。例如,你可以发送一个 POST 请求来更新字段定义:

sh 复制代码
curl -X POST -H 'Content-type:application/json' --data-binary '{
  "update-field": {
    "name": "opt_time",
    "type": "pdate",
    "indexed": true,
    "stored": true,
    "docValues": "SORTED_NUMERIC",
    "multiValued": false
  }
}' http://localhost:8983/solr/your_core/schema

这里使用的是 update-field如果不行,可以删除掉out_time,使用 add-field来添加

sh 复制代码
curl -X POST -H 'Content-type:application/json' --data-binary '{
  "add-field": {
    "name": "opt_time",
    "type": "pdate",
    "indexed": true,
    "stored": true,
    "docValues": "SORTED_NUMERIC",
    "multiValued": false
  }
}' http://admin:Oi2a@172.111.111.182:8983/solr/2-testcore/schema
相关推荐
risc1234561 天前
【lucene】向量搜索底层文件关系梳理
lucene
risc1234564 天前
【Lucene】架构
lucene
risc1234564 天前
【Lucene】lucene的searcher.search查询机制
lucene
鼠鼠我捏,要死了捏7 天前
Elasticsearch、Solr 与 OpenSearch 搜索引擎方案对比分析及选型建议
elasticsearch·solr·opensearch
TinpeaV8 天前
Elasticsearch 和 solr 的区别
大数据·elasticsearch·solr
lrh30259 天前
Custom SRP - Custom Render Pipeline
搜索引擎·全文检索·lucene
risc12345614 天前
BKD 树(Block KD-Tree)Lucene
java·数据结构·lucene
risc12345615 天前
【Lucene/Elasticsearch】**Query Rewrite** 机制
elasticsearch·jenkins·lucene
Elastic 中国社区官方博客18 天前
Elasticsearch 字符串包含子字符串:高级查询技巧
大数据·数据库·elasticsearch·搜索引擎·全文检索·lucene
阿蒙Amon25 天前
C# Linq to Objects 详解:集合处理的终极方案
c#·solr·linq