edit | blame | history | raw

两种分词器使用的最佳实践 🍻

索引时用ik_max_word,在搜索时用ik_smart。
   { "arttitle": {
            "type": "text",
            "analyzer": "ik_max_word",
            "search_analyzer": "ik_smart"
         }
     }

字段禁止动态添加映射

"dynamic" :"strict",

日期动态格式化

"dynamic_date_formats":"yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis",

别名

  • 别名添加
    POST _aliases
    {
    "actions" : [{"add" : {"index" : "student" , "alias" : "in1"}}]
    }

  • 别名删除
    POST /_aliases
    {
    "actions": [
    {"remove": {"index": "school", "alias": "in1"}}
    ]
    }

  • 别名修改
    POST _aliases
    {
    "actions" : [{"remove" : {"index" : "student" , "alias" : "in1"}}],
    "actions" : [{"add" : {"index" : "student" , "alias" : "in2"}}]
    }

config

"tagContainer": "智能标签,#转两个数组?",

```
{
    "settings": {
       "number_of_shards": "5",
       "number_of_replicas": "1"
    },
    "mappings": {
       "dynamic": "strict",
       "dynamic_date_formats": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis",
       "properties": {
         "fileName": {
          "type": "text",
          "analyzer": "ik_max_word",
          "search_analyzer": "ik_max_word"
         },
         "description": {
          "type": "text",
          "analyzer": "ik_max_word",
          "search_analyzer": "ik_smart"
         },
         "title": {
          "type": "text",
          "analyzer": "ik_max_word",
          "search_analyzer": "ik_max_word"
         },

         "videoText": {
          "type": "text",
          "analyzer": "ik_max_word",
          "search_analyzer": "ik_smart"
         },

         "tags": {
          "type": "keyword"
         },

         "personTags": {
          "type": "keyword"
         },

         "labelTags": {
          "type": "keyword"
         },

         "deptId": {
          "type": "keyword"
         },
         "storeType": {
          "type": "integer"
         },
         "id": {
          "type": "integer"
         },


         "typeId": {
          "type": "integer"
         },

         "createTime": {
          "format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis",
          "type": "date"
         },


         "groupId": {
          "type": "integer"
         },
         "status": {
          "type": "integer"
         },
         "uploadStatus": {
          "type": "integer"
         },
         "duration": {
          "type": "integer"
         },
         "height": {
          "type": "integer"
         },
         "width": {
          "type": "integer"
         },

         "dirId": {
          "type": "integer"
         },
         "videoBitrate": {
          "type": "integer"
         },


         "fileMd5": {
          "type": "keyword"
         },


         "programId": {
          "type": "integer"
         },

         "videoId": {
          "type": "integer"
         },
         "userId": {
          "type": "keyword"
         },
         "userName": {
          "type": "keyword"
         },

         "size": {
          "type": "long"
         },
         "cateId": {
          "type": "integer"
         },

         "cateIdLeaf": {
          "type": "integer"
         },
         "mediaStatus": {
          "type": "integer"
         },

         "decodeStatus": {
          "type": "integer"
         },
         "isCollect": {
          "type": "integer"
         },



         "fps": {
          "type": "integer",
          "index": false
         },
         "audioBitrate": {
          "type": "integer",
          "index": false
         },
         "previewUrl": {
          "type": "text",
          "index": false
         },
         "originalFile": {
          "type": "text",
          "index": false
         },
         "coverUrl": {
          "type": "text",
          "index": false
         },
         "format": {
          "type": "text",
          "index": false
         },
         "videoCodec": {
          "type": "text",
          "index": false
         },
         "audioCodec": {
          "type": "text",
          "index": false
         }




       }
    }
}

#remove
"videoText": "顺丰到付的",
"recordList": null,
"fileCountNumber": null,
"fileCountSize": null,
"flagRecordList": null,
"groupFileList": null,
"sizeMB": "20.83",


cateIdLeaf
tags

groupId
programId
videoCodec
audioCodec
duration
videoBitrate
audioBitrate
fps
width
height