设置update.autoCreateFields为false在Solr中不生效问题求助
Solr禁用自动字段创建后仍自动生成字段
操作流程
- 执行命令禁用字段自动创建:
curl -X POST http://localhost:8984/solr/products/config -H 'Content-Type: application/json' -d '{ "set-user-property": { "update.autoCreateFields": "false" }}' - 确认
configoverlay.json中已配置{"userProps":{"update.autoCreateFields":"false"}} - 重载集合:
curl -X POST http://localhost:8984/api/collections/products/reload - 提交含未知字段的文档进行索引:
curl http://localhost:8984/solr/products/update/json?commit=true -H "Content-Type: application/json" -d '[{"id":"123", "unknown": "fail me"}]'
异常情况
文档无错误完成索引,Solr自动创建了类型为text_general的unknown字段和类型为string的unknown_str字段,与预期不符——预期因unknown字段不存在于schema中,文档无法被索引。
环境说明
- Docker部署Solr 9.8.0
- 采用SolrCloud模式,单节点搭配嵌入式ZooKeeper
补充测试结果
测试多个与schema或动态字段均不匹配的字段(如携带日期值的xyx字段),结果仍能被索引,且Solr自动创建了类型为pdate的对应字段。
集合创建命令
curl -X POST http://localhost:8984/api/collections -H 'Content-Type: application/json' -d '{ "name": "products", "numShards": 1, "replicationFactor": 1 }'
内容的提问来源于stack exchange,提问作者BenA
相关产品推荐
相关产品推荐

