2

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

{  
  "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-demo”而不填充子类型“chow-clfg”,并且文档拒绝索引。(没有文档被 Elasticsearach 索引)

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

  1. 我的映射结构错了吗?
  2. 是否必须同时将父子索引一起索引才能成功索引数据?

在这个问题上真的需要帮助才能让我的项目取得进展!谢谢!

4

1 回答 1

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

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

于 2012-12-21T11:34:58.827 回答