如何为Elasticsearch构建父母/子制图



我尝试使用以下映射来索引我的数据:

{  
  "mappings": {
   "chow-demo": {
    "properties": {
     "@fields": {
      "dynamic": "true",
      "properties": {
        "asgid": {
          "type": "string",
          "analyzer": "keyword"
        },
        "asid": {
          "type": "long"
        },
        "astid": {
          "type": "long"
        },
        "clfg": {
          "analyzer": "keyword",
          "type": "string"
        },
        "httpcode": {
          "type": "long"
        },
        "oid": {
          "type": "string"
        },
        "onid": {
          "type": "long"
        },
        "ptrnr": {
          "analyzer": "keyword",
          "type": "string"
        },
        "pguid": {
          "analyzer": "keyword",
          "type": "string"
        },
        "ptid": {
          "type": "long"
        },
        "sid": {
          "type": "long"
        },
        "src_url": {
          "analyzer": "keyword",
          "type": "string"
        },
        "title": {
          "analyzer": "keyword",
          "type": "string"
        },
        "ts": {
          "type": "long"
        }
       }
      },
      "@timestamp": {
       "format": "dateOptionalTime",
       "type": "date"
      },
      "@message": {
       "type": "string"
      },
      "@source": {
       "type": "string"
      },
      "@type": {
       "analyzer": "keyword",
       "type": "string"
      },
      "@tags": {
       "type": "string"
      },
      "@source_host": {
       "type": "string"
      },
      "@source_path": {
       "type": "string"
      }
     }
    },
   "chow-clfg": {
    "_parent": {
     "type": "chow-demo"
    },
    "dynamic": "true",
    "properties": {
     "_ttl": {
      "enabled": true,
      "default": "1h"
     },
     "clfg": {
      "analyzer": "keyword",
      "type": "string"
     },
     "@timestamp": {
      "format": "dateOptionalTime",
      "type": "date"
     },
     "count": {
      "type": "long"
     }
    }
   }
  }
}

我试图在不填充子类型的" chow-clfg"的情况下填充父型" chow-demo",并且该文档拒绝索引。(没有将文件索引到ElasticSearach)

当我取出" chow-clfg"的孩子映射时,它确实像往常一样正确地索引。因此,我有以下问题:

  1. 我的映射结构是错误的吗?
  2. 必须同时将父母和子女一起索引,然后将数据成功索引?

在这个问题中确实需要帮助才能进步!谢谢!

  1. 是的,您的映射是错误的。_ttl元素在chow-clfg类型中应高一个级别。换句话说,_ttl应与_parent相同。但是,我不太确定这个问题如何影响您的索引能力。

  2. 父母和孩子不必被索引在一起。

最新更新