mapper [clientip] имеет разные значения [норм], не может быть изменен с отключенного на включенный] - PullRequest
0 голосов
/ 14 мая 2018

Mapper для [clientip] конфликтует с существующим отображением в других типах: \ n [mapper [clientip] имеет другие значения [норм], не может измениться с отключенного на включенное]

Elasticsearch 6.2.4

Мы используем logstash +asticsearch, чтобы получить некоторые показатели пропускной способности при использовании нашего облачного фронта.Вот как logstash анализирует вещи: https://gist.github.com/chrisan/1c5ce5beacfc0e124d39fa842f051857#file-logstash-api-conf

Это генерирует индексы, такие как: https://gist.github.com/chrisan/1c5ce5beacfc0e124d39fa842f051857#file-indicies

С такими сопоставлениями, как: https://gist.github.com/chrisan/1c5ce5beacfc0e124d39fa842f051857#file-mappings

Меня попросили различитьIP-адреса, и я попытался использовать агрегированный запрос:

{
  "size": 0,
    "aggs" : {
        "distinct_ips" : {
            "filter" : { "term": { "company" : "XXX" } },
            "aggs" : {
                "cardinality" : { "cardinality": {"field": "clientip"   } }
            }
        }
    }
}

Но это возвращает:

{
    "error": {
        "root_cause": [
            {
                "type": "illegal_argument_exception",
                "reason": "Fielddata is disabled on text fields by default. Set fielddata=true on [clientip] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead."
            }
        ],
        "type": "search_phase_execution_exception",
        "reason": "all shards failed",
        "phase": "query",
        "grouped": true,
        "failed_shards": [
            {
                "shard": 0,
                "index": "logstash-2018.01.01",
                "node": "dO1JCnAnSmmk5EfDmfYgqQ",
                "reason": {
                    "type": "illegal_argument_exception",
                    "reason": "Fielddata is disabled on text fields by default. Set fielddata=true on [clientip] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead."
                }
            }
        ]
    },
    "status": 400
}

Поэтому я попытался обновить это с помощью сопоставления

PUT / * / _/ _doc? update_all_types

{
  "properties": {
    "clientip": {
      "type":     "text",
      "fielddata": true
    }
  }
}

Что возвращает:

{
    "error": {
        "root_cause": [
            {
                "type": "illegal_argument_exception",
                "reason": "Mapper for [clientip] conflicts with existing mapping in other types:\n[mapper [clientip] has different [norms] values, cannot change from disable to enabled]"
            }
        ],
        "type": "illegal_argument_exception",
        "reason": "Mapper for [clientip] conflicts with existing mapping in other types:\n[mapper [clientip] has different [norms] values, cannot change from disable to enabled]"
    },
    "status": 400
}

Что я делаю не так?

1 Ответ

0 голосов
/ 17 мая 2018

Разобрался, пришлось все удалить и затем обновить шаблон logstash с помощью

{
        "template": "logstash",
        "order": 0,
        "version": 60001,
        "index_patterns": [
            "logstash-*"
        ],
        "settings": {
            "index": {
                "refresh_interval": "5s"
            }
        },
        "mappings": {
            "_default_": {
                "dynamic_templates": [
                    {
                        "message_field": {
                            "path_match": "message",
                            "match_mapping_type": "string",
                            "mapping": {
                                "type": "text",
                                "norms": false
                            }
                        }
                    },
                    {
                        "string_fields": {
                            "match": "*",
                            "match_mapping_type": "string",
                            "mapping": {
                                "type": "text",
                                "norms": false,
                                "fields": {
                                    "keyword": {
                                        "type": "keyword",
                                        "ignore_above": 256
                                    }
                                }
                            }
                        }
                    }
                ],
                "properties": {
                    "@timestamp": {
                        "type": "date"
                    },
                    "@version": {
                        "type": "keyword"
                    },
                    "clientip": {
                        "type":     "text",
                        "fields": {
                        "keyword": { 
                          "type": "keyword"
                        }
                      }
                    },
                    "company": { 
                      "type": "text",
                      "fields": {
                        "keyword": { 
                          "type": "keyword"
                        }
                      }
                    },
                    "geoip": {
                        "dynamic": true,
                        "properties": {
                            "ip": {
                                "type": "ip"
                            },
                            "location": {
                                "type": "geo_point"
                            },
                            "latitude": {
                                "type": "half_float"
                            },
                            "longitude": {
                                "type": "half_float"
                            }
                        }
                    }
                }
            }
        },
        "aliases": {}
    }

И тогда я мог бы запросить с помощью

"aggs": {
   "distinct_ips": {
     "cardinality": {
       "field": "clientip.keyword"
     }
   }
 }
...