canal.adapter同步 ES 索引创建 大概配置详情
PUT /test
{
"settings": {
"number_of_shards": 1,
"number_of_replicas": 0,
"analysis": {
"analyzer": {
"htmlStripAnalyzer": {
"filter": ["lowercase", "classic", "trim"],
"char_filter": ["html_strip"],
"type": "custom",
"tokenizer": "standard"
},
"chinese_analyzer": {
"type": "custom",
"tokenizer": "ik_max_word" // 使用 IK 分词器进行中文分词
}
},
"char_filter": {
"html_strip": {
"type": "html_strip"
}
},
"tokenizer": {
"ik_max_word": {
"type": "ik_max_word"
}
}
}
},
"mappings": {
"dynamic": "true",
"_source": {
"excludes": [
"fujcontent",
"projdetail"
]
},
"date_detection": false,
"numeric_detection": false,
"properties": {
"results_id": {
"type": "integer",
"fields": {
"raw": {
"type": "keyword",
"null_value": "NULL",
"ignore_above": 256
}
}
},
"notice_num": {
"type": "text",
"fields": {
"raw": {
"type": "keyword",
"null_value": "NULL",
"ignore_above": 256
}
}
},
"organ": { "type": "text", "analyzer": "htmlStripAnalyzer" },
"owner": { "type": "text", "analyzer": "htmlStripAnalyzer" },
"project": { "type": "text", "analyzer": "htmlStripAnalyzer","copy_to": "combined" }, // 关联关系 "copy_to": "combined"
"combined": { // 定义关键词(关联关系) 搜索 combined 字段,显示其他两项关联字段
"type": "text"
},
"content": { "type": "text", "analyzer": "ik_max_word","copy_to": "combined" }, // 关联关系 "copy_to": "combined"
"html": { "type": "text", "analyzer": "htmlStripAnalyzer" },
"by1": { "type": "keyword" },
"editip": { "type": "text", "analyzer": "chinese_analyzer" }, // 使用中文分析器
"bid_time": {
"type": "date",
"format": "strict_date_optional_time",
"null_value": "1970-01-01T00:00:00",
"copy_to": "combined"
},
"jointime": { "type": "date", "format": "yyyy-MM-dd'T'HH:mm:ss" },
分析器配置:
htmlStripAnalyzer: 使用 html_strip 字符过滤器,lowercase, classic, 和 trim 过滤器。适用于处理 HTML 内容,清理标签并进行标准化处理。
chinese_analyzer: 使用 ik_max_word 分词器进行中文分词。适用于中文文本的详细分词处理。
字段配置:
project 和 content 字段都配置了 copy_to 为 combined,这意味着它们的内容会被复制到 combined 字段,以便 进行跨字段搜索。
combined 字段没有配置分析器或分词器,Elasticsearch 会默认使用 standard 分词器。如果你需要对 combined 字段使用特定的分析器或分词器,可以在 combined 字段中进行设置。
editip 字段使用了 chinese_analyzer,适合处理中文文本。
bid_time 字段使用了 date 类型,并且配置了 copy_to 为 combined,这意味着时间信息也会被复制到 combined 字段。
结构 根据自己本机mysql结构配置
作者只是把结构需要的大概配置记录一下