gpt4 book ai didi

java - 如何在不重新索引数据的情况下更新 ElasticSearch 映射?

转载 作者:行者123 更新时间:2023-11-30 06:54:46 25 4
gpt4 key购买 nike

我使用elasticsearch 2.2.0并创建数据映射如下:

{
"DOCU": {
"_source": { "excludes" : ["fileAttachment.fileContent", "fileAttachmentFr.fileContent", "fileAttachmentEn.fileContent", "contentBody", "contentBodyFr", "contentBodyEn", "geoLocations.boundaries"] },
"properties":{
"id" : { "type" : "string", "store" : "true" },

"categoryId" : { "type" : "string", "store" : "true" } ,
"categoryCode" : { "type" : "string", "store" : "true" } ,
"categoryDesc" : { "type" : "string", "store" : "true" } ,

"typeId" : { "type" : "string", "store" : "true" } ,
"typeCode" : { "type" : "string", "store" : "true" } ,
"typeDesc" : { "type" : "string", "store" : "true" } ,

"domainId" : { "type" : "string", "store" : "true" } ,
"domainCode" : { "type" : "string", "store" : "true" } ,
"domainDesc" : { "type" : "string", "store" : "true" } ,

"groupId" : { "type" : "string", "store" : "true" } ,
"groupCode" : { "type" : "string", "store" : "true" } ,
"groupDesc" : { "type" : "string", "store" : "true" } ,

"title" : { "type" : "string", "store" : "true" } ,
"titleFr" : { "type" : "string", "store" : "true" } ,
"titleEn" : { "type" : "string", "store" : "true" } ,

"subTitle" : { "type" : "string", "store" : "true" } ,
"subTitleFr" : { "type" : "string", "store" : "true" } ,
"subTitleEn" : { "type" : "string", "store" : "true" } ,

"summary" : { "type" : "string", "store" : "true" } ,
"summaryFr" : { "type" : "string", "store" : "true" } ,
"summaryEn" : { "type" : "string", "store" : "true" } ,

"body" : { "type" : "string", "store" : "true" } ,
"bodyFr" : { "type" : "string", "store" : "true" } ,
"bodyKh" : { "type" : "string", "store" : "true" } ,

"contentBody" : {
"type" : "attachment",
"fields": {
"content": { "type": "string", "term_vector":"with_positions_offsets", "store": true, "analyzer" : "english"}
}
},
"contentBodyFr" : {
"type" : "attachment",
"fields": {
"content": { "type": "string", "term_vector":"with_positions_offsets", "store": true, "analyzer" : "french"}
}
},
"contentBodyEn" : {
"type" : "attachment",
"fields": {
"content": { "type": "string", "term_vector":"with_positions_offsets", "store": true, "analyzer" : "english"}
}
},

"wkfStatusId" : {"type" : "integer", "store" : "true"},

"owner" : {"type" : "string", "store" : "true"},
"createdDate": { "type" : "date", "store" : "true", "format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"},
"modifiedDate":{ "type" : "date", "store" : "true", "format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"},

"rank" : { "type" : "float", "store" : "true" },
"nbViewed" : { "type" : "integer", "store" : "true" },
"nbDownloaded" : { "type" : "integer", "store" : "true" },
"avgRating" : { "type" : "float", "store" : "true" },
"nbComment" : { "type" : "integer", "store" : "true" },

"contributors" : {
"properties":{
"id" : { "type" : "string", "store" : "true" },
"type" : { "type" : "string", "store" : "true" } ,
"contributorId" : { "type" : "string", "store" : "true" } ,
"contributorName" : { "type" : "string", "store" : "true" } ,
"orgCatId" : { "type" : "string", "store" : "true" } ,
"orgTypeId" : { "type" : "string", "store" : "true" } ,
"orgId" : { "type" : "string", "store" : "true" } ,
"orgName" : { "type" : "string", "store" : "true" }
}
},

"projectES" : {
"properties":{
"id" : { "type" : "string", "store" : "true" },
"orgId" : { "type" : "string", "store" : "true" } ,
"orgName" : { "type" : "string", "store" : "true" } ,
"startDate": { "type" : "date", "store" : "true", "format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"},
"endDate":{ "type" : "date", "store" : "true", "format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"},
"website" : { "type" : "string", "store" : "true" },
"budget" : { "type" : "string", "store" : "true" },
"funders" : { "type" : "string", "store" : "true", "term_vector": "with_positions_offsets" }
}
},

"organizationES" : {
"properties":{
"id" : { "type" : "string", "store" : "true" },
"categoryId" : { "type" : "string", "store" : "true" } ,
"categoryDesc" : { "type" : "string", "store" : "true" } ,
"typeId" : { "type" : "string", "store" : "true" } ,
"typeDesc" : { "type" : "string", "store" : "true" } ,
"shortName" : { "type" : "string", "store" : "true" },
"website" : { "type" : "string", "store" : "true" },
"email" : { "type" : "string", "store" : "true" },
"tel" : { "type" : "string", "store" : "true" },
"address" : { "type" : "string", "store" : "true" }
}
},

"employeeES" : {
"properties":{
"id" : { "type" : "string", "store" : "true" },
"categoryId" : { "type" : "string", "store" : "true" } ,
"categoryDesc" : { "type" : "string", "store" : "true" } ,
"genderId" : { "type" : "string", "store" : "true" } ,
"genderDesc" : { "type" : "string", "store" : "true" } ,
"email" : { "type" : "string", "store" : "true" },
"tel" : { "type" : "string", "store" : "true" },
"country" : { "type" : "string", "store" : "true" },
"city" : { "type" : "string", "store" : "true" },
"bio" : { "type" : "string", "store" : "true" }
}
},

"memberES" : {
"properties":{
"id" : { "type" : "string", "store" : "true" },
"memberTypeId" : { "type" : "string", "store" : "true" } ,
"memberTypeDesc" : { "type" : "string", "store" : "true" } ,
"isOnline" : { "type" : "string", "store" : "true" } ,
"isPrivate" : { "type" : "string", "store" : "true" } ,
"individu" : {
"properties":{
"id" : { "type" : "string", "store" : "true" },
"categoryId" : { "type" : "string", "store" : "true" } ,
"categoryDesc" : { "type" : "string", "store" : "true" } ,
"genderId" : { "type" : "string", "store" : "true" } ,
"genderDesc" : { "type" : "string", "store" : "true" } ,
"email" : { "type" : "string", "store" : "true" },
"tel" : { "type" : "string", "store" : "true" },
"country" : { "type" : "string", "store" : "true" },
"city" : { "type" : "string", "store" : "true" },
"bio" : { "type" : "string", "store" : "true" }
}
}
}
},

"urlContent" : {"type" : "string", "store" : "true"},

"isParsing" : { "type" : "boolean", "store" : "true" } ,
"isSelfPublished" : { "type" : "boolean", "store" : "true" } ,

"isPublished" : { "type" : "boolean", "store" : "true" } ,
"publicationDate" : { "type" : "date", "store" : "true", "format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"} ,

"isPublic" : { "type" : "boolean", "store" : "true" } ,
"isVisible" : { "type" : "boolean", "store" : "true" } ,
"isLocked" : { "type" : "boolean", "store" : "true" } ,

"tagNames" : { "type" : "string", "store" : "true", "term_vector": "with_positions_offsets" },

"geoLocationsNames": { "type" : "string", "store" : "true", "term_vector": "with_positions_offsets" },
"geoLocations" :{
"properties":{
"id" : { "type" : "integer", "store" : "true" },
"code" : { "type" : "string", "store" : "true" },
"desc" : { "type" : "string", "store" : "true" },
"descEn" : { "type" : "string", "store" : "true" },
"point" : { "type" : "geo_point"},
"boundaries" : { "type" : "geo_shape"}
},
"type" : "nested"
},

"fileAttachment" : {
"properties":{
"fileContent" : {
"type" : "attachment",
"fields": {
"content": { "type": "string", "term_vector":"with_positions_offsets", "store": true, "analyzer" : "english"}
}
},
"contentType" : { "type" : "string", "store" : "true", "index" : "not_analyzed" },
"lastModifiedDate":{ "type" : "date", "store" : "true", "format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"},
"indexing_date": { "type" : "date", "store" : "true", "format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"},
"filesize": { "type" : "long", "store" : "true" },
"indexed_chars": { "type" : "long", "store" : "true"},
"filename": { "type" : "string", "store" : "true", "index" : "not_analyzed" },
"url": { "type" : "string", "store" : "true", "index" : "no" }
}
},

"fileAttachmentEn" : {
"properties":{
"fileContent" : {
"type" : "attachment",
"fields": {
"content": { "type": "string", "term_vector":"with_positions_offsets", "store": true, "analyzer" : "english"}
}
},
"contentType" : { "type" : "string", "store" : "true", "index" : "not_analyzed" },
"lastModifiedDate":{ "type" : "date", "store" : "true", "format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"},
"indexing_date": { "type" : "date", "store" : "true", "format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"},
"filesize": { "type" : "long", "store" : "true" },
"indexed_chars": { "type" : "long", "store" : "true"},
"filename": { "type" : "string", "store" : "true", "index" : "not_analyzed" },
"url": { "type" : "string", "store" : "true", "index" : "no" }
}
},

"fileAttachmentFr" : {
"properties":{
"fileContent" : {
"type" : "attachment",
"fields": {
"content": { "type": "string", "term_vector":"with_positions_offsets", "store": true, "analyzer" : "english"}
}
},
"contentType" : { "type" : "string", "store" : "true", "index" : "not_analyzed" },
"lastModifiedDate":{ "type" : "date", "store" : "true", "format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"},
"indexing_date": { "type" : "date", "store" : "true", "format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"},
"filesize": { "type" : "long", "store" : "true" },
"indexed_chars": { "type" : "long", "store" : "true"},
"filename": { "type" : "string", "store" : "true", "index" : "not_analyzed" },
"url": { "type" : "string", "store" : "true", "index" : "no" }
}
}
}

}}

如何从映射中删除排除字段(如下所示):

"_source": { "excludes" : ["fileAttachment.fileContent", "fileAttachmentFr.fileContent", "fileAttachmentEn.fileContent", "contentBody", "contentBodyFr", "contentBodyEn", "geoLocations.boundaries"] }

我不想重新索引我的数据,因为这需要一整天才能完成。请帮忙:)

最佳答案

在不重新索引的情况下无法更改 ElasticSearch 映射。

不过你可以看看 https://www.elastic.co/blog/changing-mapping-with-zero-downtime

这展示了如何在几乎零停机时间的情况下重新建立索引

关于java - 如何在不重新索引数据的情况下更新 ElasticSearch 映射?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42063130/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com