【问题标题】:How to build a parent/child mapping for Elasticsearch?如何为 Elasticsearch 构建父/子映射?
【发布时间】:2012-12-21 19:34:58
【问题描述】:

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

{  
  "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. 是否必须同时将父子索引一起索引才能成功索引数据?

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

【问题讨论】:

    标签: elasticsearch


    【解决方案1】:
    1. 是的,您的映射错误。 _ttl 元素应该比chow-clfg 类型高一级。换句话说,_ttl 应该与_parent 处于同一级别。但是,我不太确定这个问题会如何影响您的索引能力。

    2. 不必将父项和子项编入索引。

    【讨论】:

    • 是的!谢谢伊莫托夫!它影响了我的索引能力。第一次尝试后有效!
    猜你喜欢
    • 1970-01-01
    • 2021-03-23
    • 2016-01-21
    • 2019-05-18
    • 2017-12-15
    • 2020-07-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多