企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
## 一、索引的维护 如果建立的检索数据模型发生变更,需要强制的删除一次索引,然后重建之,否则,索引不会被更新,举例; ``` GET /rayphonenumber/_mapping?pretty ``` 结果: ``` { "rayphonenumber" : { "mappings" : { "properties" : { "_class" : { "type" : "keyword", "index" : false, "doc_values" : false }, "area" : { "type" : "keyword" }, "full-number" : { "type" : "text", "fields" : { "keyword" : { "type" : "keyword", "ignore_above" : 256 } } }, "id" : { "type" : "text", "fields" : { "keyword" : { "type" : "keyword", "ignore_above" : 256 } } }, "number" : { "type" : "keyword" }, "price" : { "type" : "long" }, "service-provider" : { "type" : "keyword" }, "sku-id" : { "type" : "long" }, "spu-id" : { "type" : "long" } } } } } ``` 其中有些字段,是在后期增加和变化的,但索引并没有随着数据变化和自动更新,可以通过强制删除索引,然后重建一次,来解决这个问题; ``` elasticsearchOperations.indexOps(PhoneNumber.class).delete() ``` 或者直接用命令: ``` DELETE /rayphonenumber ``` 然后,再重新导入数据,即可自动创建更新的索引; ``` { "rayphonenumber" : { "mappings" : { "properties" : { "_class" : { "type" : "keyword", "index" : false, "doc_values" : false }, "area" : { "type" : "text", "analyzer" : "ik_smart" }, "full-number" : { "type" : "keyword" }, "number" : { "type" : "text" }, "price" : { "type" : "long" }, "service-provider" : { "type" : "text", "analyzer" : "ik_smart" }, "sku-id" : { "type" : "long" }, "spu-id" : { "type" : "long" } } } } } ```