簡體   English   中英

如何在不重新索引數據的情況下更新 ElasticSearch Mapping?

[英]How to update ElasticSearch Mapping without reindex data?

我使用 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/changed-mapping-with-zero-downtime

這顯示了如何在幾乎零停機的情況下重新索引

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM