我正在尝试使用电子邮件映射。我想为收件人使用嵌套类型。我尝试使用此映射但我不了解弹性搜索问题:
{
"template": "test*",
"settings":{
"index":{
"analysis":{
"analyzer":{
"email":{
"tokenizer":"keyword",
"filter":"lowercase"
}
}
}
}
},
"mappings": {
"logs": {
"properties": {
"@timestamp": {
"type": "date",
"format": "strict_date_optional_time||epoch_millis"
},
"recipients": {
"type" : "nested",
"properties": {
"rcptto": {"type": "string", "analyzer":"email" }
}
}
}
}
}
}
当我发布我的数据时,我得到了:
{
"error": {
"root_cause": [
{
"type": "illegal_argument_exception",
"reason": "Mapper for [recipients] conflicts with existing mapping in other types[object mapping [recipients] can't be changed from nested to non-nested]"
}
],
"type": "illegal_argument_exception",
"reason": "Mapper for [recipients] conflicts with existing mapping in other types[object mapping [recipients] can't be changed from nested to non-nested]"
},
"status": 400
}
我仔细观察,但我不明白。当我尝试创建记录到/ postfix / foo例如,它可以工作,但在我的映射中我有:
"mappings": {
"logs": {
然后,当我尝试在/ postfix / logs中创建记录时,recipients.rcptto不存在。
我不明白的第二件事。我删除了postfix *,然后我试图创建一个记录,第一次失败(见下面的日志),下一个相同的请求它工作:'(
# curl -XDELETE http://localhost:9200/postfix*
{"acknowledged":true}
# curl -POST http://localhost:9200/postfix/54 -d '
{
"status" : "sent",
"queueid" : "3nTgBP6Mrpz18dwD",
"postfixdaemon" : "smtpd",
"recipients" : [
{
"rcptto" : "misterA@customer.fr"
}
],
"mailfrom" : "misterB@something.fr",
"clienthostname" : "server.fr",
"pid" : 7996,
"delays" : "0.06/0/0/0.28",
"logsource" : "smtp2",
"total_delay" : 1,
"mailsize" : 23792,
"delay" : 0.34,
"program" : "postfix",
"entry_date" : "Jan 5 00:45:33",
"timestamp" : "Jan 5 00:45:33",
"removed" : "True",
"@version" : "1",
"@timestamp" : "2016-01-04T23:45:33.000Z"
}'
{"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"Mapper for [recipients] conflicts with existing mapping in other types[object mapping [recipients] can't be changed from nested to non-nested]"}],"type":"illegal_argument_exception","reason":"Mapper for [recipients] conflicts with existing mapping in other types[object mapping [recipients] can't be changed from nested to non-nested]"},"status":400}
# curl -POST http://localhost:9200/postfix/54 -d '
{
"status" : "sent",
"queueid" : "3nTgBP6Mrpz18dwD",
"postfixdaemon" : "smtpd",
"recipients" : [
{
"rcptto" : "misterA@customer.fr"
}
],
"mailfrom" : "misterB@something.fr",
"clienthostname" : "server.fr",
"pid" : 7996,
"delays" : "0.06/0/0/0.28",
"logsource" : "smtp2",
"total_delay" : 1,
"mailsize" : 23792,
"delay" : 0.34,
"program" : "postfix",
"entry_date" : "Jan 5 00:45:33",
"timestamp" : "Jan 5 00:45:33",
"removed" : "True",
"@version" : "1",
"@timestamp" : "2016-01-04T23:45:33.000Z"
}'
{"_index":"postfix","_type":"54","_id":"AVPm6QFs7nZqZ6kMnJ7-","_version":1,"_shards":{"total":2,"successful":1,"failed":0},"created":true}
你能理解这种行为吗?
Elasticsearch日志:
[2016-04-05 17:01:45,902][DEBUG][action.admin.indices.mapping.put] [Elastic1.xxxxx] failed to put mappings on indices [[postfix]], type [54]
java.lang.IllegalArgumentException: Mapper for [recipients] conflicts with existing mapping in other types[object mapping [recipients] can't be changed from nested to non-nested]
GET / postfix * / _ mapping
{
"postfix": {
"mappings": {
"54": {},
"logs": {
"properties": {
"@timestamp": {
"type": "date",
"format": "strict_date_optional_time||epoch_millis"
},
"@version": {
"type": "string"
},
"clienthostname": {
"type": "string"
},
"clientip": {
"type": "ip"
},
"deferred": {
"type": "boolean"
},
"delay": {
"type": "double"
},
"delays": {
"type": "string"
},
"dsn": {
"type": "string"
},
"entry_date": {
"type": "string"
},
"lastqueueid": {
"type": "string"
},
"logsource": {
"type": "string"
},
"mailfrom": {
"type": "string",
"index": "not_analyzed"
},
"mailsize": {
"type": "long"
},
"numberofrecipients": {
"type": "long"
},
"pid": {
"type": "long"
},
"postfixdaemon": {
"type": "string"
},
"program": {
"type": "string"
},
"queueid": {
"type": "string"
},
"recipients": {
"type": "nested",
"properties": {
"rcptto": {
"type": "string",
"analyzer": "email"
}
}
},
"relay": {
"type": "string"
},
"relayip": {
"type": "string"
},
"removal_time": {
"type": "string"
},
"removed": {
"type": "string"
},
"status": {
"type": "string"
},
"tags": {
"type": "string"
},
"timestamp": {
"type": "string"
},
"total_delay": {
"type": "long"
}
}
}
}
}
}