lucene 在ElasticSearch中创建索引时出错

qeeaahzv  于 2022-11-07  发布在  Lucene
关注(0)|答案(1)|浏览(216)

我是新的ElasticSearch,我试图创建索引与下面的Map,我发现网上和使用kibana作为我的客户端,它抛出错误。

PUT /local_test
    {
      "settings": {
        "index.mapping.total_fields.limit": 1000,
        "index.mapping.depth.limit": 20,
        "index.mapping.nested_fields.limit": 50,
        "number_of_shards": 5,
        "number_of_replicas": 1,
        "analysis": {
          "analyzer": {
            "edge_ngram_analyzer": {
              "type": "custom",
              "tokenizer": "edge_ngram_tokenizer",
              "filter": [
                "lowercase",
                "en_stopwords"
              ]
            },
            "standard_custom": {
              "type": "custom",
              "char_filter": [
                "punctuation_remap"
              ],
              "tokenizer": "standard",
              "filter": [
                "lowercase",
                "en_stopwords"
              ]
            },
            "lowercase_keyword": {
              "type": "custom",
              "tokenizer": "keyword",
              "filter": [
                "lowercase"
              ]
            }
          },
          "tokenizer": {
            "edge_ngram_tokenizer": {
              "type": "edge_ngram",
              "min_gram": 2,
              "max_gram": 50,
              "token_chars": [
                "letter",
                "digit"
              ]
            }
          },
          "filter": {
            "en_stopwords": {
              "type": "stop",
              "stopwords": "_english_"
            }
          },
          "char_filter": {
            "punctuation_remap": {
              "type": "mapping",
              "mappings": [
                ". => -",
                ": => -",
                "' => -"
              ]
            }
          }
        }
      },
      "mappings": {
        "local_test": {
          "_all": {
            "enabled": false
          },
          "properties": {
            "id": {
              "type": "keyword"
            },
            "user_id": {
              "type": "keyword"
            },
            "created_at": {
              "type": "date",
              "format": "yyyy-MM-dd HH:mm:ss||epoch_millis"
            },
            "docvalue": {
              "type": "object",
              "dynamic": false,
              "enabled": true,
              "properties": {
                "key": {
                  "type": "text",
                  "analyzer": "lowercase_keyword"
                },
                "value": {
                  "type": "text",
                  "analyzer": "lowercase_keyword"
                }
              }
            },
            "recurring": {
              "type": "boolean"
            },
            "amount": {
              "type": "long"
            }
          }
        }
      }
    }

“类型”:“Map器解析异常”,“原因”:“根Map定义具有不支持的参数:[本地测试(_T):{_all={已启用=假},属性={金额={类型=长整型},用户标识={类型=关键字},重复性={类型=布尔型},创建时间={格式=yyyy-MM-dd HH:mm:ss|| epoch_米利斯,类型=日期},id={类型=关键字},docvalue={动态=假,类型=对象,启用=真,属性={值={分析器=小写关键字,类型=文本},关键字={分析器=小写关键字,类型=文本}}}}}]”

pw9qyyiw

pw9qyyiw1#

以下是您请求中的两个问题,我假设您使用的是最新的主要版本ie 7.X。
1.您需要删除最新版本中删除的_all。请参阅this official blog on this change
1.删除您的类型local_test,因为最新版本中也删除了类型。请参阅the removal of types以了解更多信息。
因此,使用以下请求可以正常工作:

放置/本地测试

{
    "settings": {
        "index.mapping.total_fields.limit": 1000,
        "index.mapping.depth.limit": 20,
        "index.mapping.nested_fields.limit": 50,
        "number_of_shards": 5,
        "number_of_replicas": 1,
        "analysis": {
            "analyzer": {
                "edge_ngram_analyzer": {
                    "type": "custom",
                    "tokenizer": "edge_ngram_tokenizer",
                    "filter": [
                        "lowercase",
                        "en_stopwords"
                    ]
                },
                "standard_custom": {
                    "type": "custom",
                    "char_filter": [
                        "punctuation_remap"
                    ],
                    "tokenizer": "standard",
                    "filter": [
                        "lowercase",
                        "en_stopwords"
                    ]
                },
                "lowercase_keyword": {
                    "type": "custom",
                    "tokenizer": "keyword",
                    "filter": [
                        "lowercase"
                    ]
                }
            },
            "tokenizer": {
                "edge_ngram_tokenizer": {
                    "type": "edge_ngram",
                    "min_gram": 2,
                    "max_gram": 50,
                    "token_chars": [
                        "letter",
                        "digit"
                    ]
                }
            },
            "filter": {
                "en_stopwords": {
                    "type": "stop",
                    "stopwords": "_english_"
                }
            },
            "char_filter": {
                "punctuation_remap": {
                    "type": "mapping",
                    "mappings": [
                        ". => -",
                        ": => -",
                        "' => -"
                    ]
                }
            }
        }
    },
    "mappings": {
        "properties": {
            "id": {
                "type": "keyword"
            },
            "user_id": {
                "type": "keyword"
            },
            "created_at": {
                "type": "date",
                "format": "yyyy-MM-dd HH:mm:ss||epoch_millis"
            },
            "docvalue": {
                "type": "object",
                "dynamic": false,
                "enabled": true,
                "properties": {
                    "key": {
                        "type": "text",
                        "analyzer": "lowercase_keyword"
                    },
                    "value": {
                        "type": "text",
                        "analyzer": "lowercase_keyword"
                    }
                }
            },
            "recurring": {
                "type": "boolean"
            },
            "amount": {
                "type": "long"
            }
        }
    }
}

输出

{
    "acknowledged": true,
    "shards_acknowledged": true,
    "index": "local_test"
}

相关问题