【问题标题】:Elasticsearch 7: Failed to parse mapping [_doc]: Root mapping definition has unsupported parameters:Elasticsearch 7:无法解析映射 [_doc]:根映射定义具有不受支持的参数:
【发布时间】:2019-10-14 19:57:17
【问题描述】:

我的 NEST 代码曾经使用 Elasticsearch 版本 6,但在使用 Elastichsearch 版本 7 时会抛出以下错误:

无法解析映射 [_doc]:根映射定义有 不支持的参数:

我看到 this question 解释了 ES 7 中不推荐使用映射类型...我不确定这是否是我的问题?如何解决这个问题?

这是我生成索引的代码:

var createIndexResponse = ElasticClient.CreateIndex(IndexName, c => c
    .Settings(st => st
        .Analysis(an => an
            .Analyzers(anz => anz
                .Custom("result_suggester_analyzer", rsa => rsa
                    .Tokenizer("standard")
                    .CharFilters("html_strip", "mapped_words_char_filter")
                    .Filters(new string[] { "english_possessive_stemmer", "lowercase", "asciifolding", "stop_words", "english_stemmer", "edge_ngram_token_filter", "unique" })
                )
                .Custom("custom_english_analyzer", ce => ce
                    .Tokenizer("standard")
                    .CharFilters("html_strip", "mapped_words_char_filter")
                    .Filters(new string[] { "english_possessive_stemmer", "lowercase", "asciifolding", "stop_words", "english_stemmer", "unique" })
                )
            )
            .Normalizers(nor => nor
                .Custom("custom_ignore_case_normalizer", icn => icn
                    .CharFilters("mapped_words_char_filter")
                    .Filters(new string[] { "lowercase", "asciifolding" })
                )
            )
            .CharFilters(cf => cf
                .Mapping("mapped_words_char_filter", md => md
                    .Mappings(
                        "C# => csharp"
                    )
                )
            )
            .TokenFilters(tfd => tfd
                .EdgeNGram("edge_ngram_token_filter", engd => engd
                    .MinGram(2)
                    .MaxGram(10)
                )
                .Stop("stop_words", sfd => sfd.StopWords(_stopWords))
                .Stemmer("english_stemmer", esd => esd.Language("english"))
                .Stemmer("english_possessive_stemmer", epsd => epsd.Language("possessive_english"))
            )
        )
    )
    .Mappings(m => m.Map<AdDocument>(d => d.AutoMap()))); 

这是MyDocument

[ElasticsearchType(Name = "ad")]
public class AdDocument
{
    public long Id { get; set; }

    [Text(Analyzer = "custom_english_analyzer", SearchAnalyzer = "custom_english_analyzer")]
    public string FirstName { get; set; }

    // searchable properties from AdBase
    public bool IsActive { get; set; }

    [Text(Analyzer = "custom_english_analyzer", SearchAnalyzer = "custom_english_analyzer")]
    public string Title { get; set; }

    public short AdDurationInDays { get; set; }

    public DateTime AdStartTime { get; set; }

    [Keyword(Index = false)]   // Keyword => not analyzed
    public string MainPhotoUrl { get; set; }

    [Text(Analyzer = "custom_english_analyzer", SearchAnalyzer = "custom_english_analyzer")]
    public string StoreName { get; set; }

    // searchable properties from Address
    public GeoLocation GeoLocation { get; set; }

    [Keyword(Normalizer = "custom_ignore_case_normalizer")]   // keywords => not analyzed, use ignore case normalizer otherwise search would be case sensitive
    public string Suburb { get; set; }

    // Price is used when something is being sold, in case of real estate rental it indicates the rent value, in case of Jobs it is not used (we use salary) and services have not price
    public decimal? Price { get; set; }

    public DateTime? AvailableFrom { get; set; }

    public bool? IsFurnished { get; set; }

    public long? LandArea { get; set; }

    public short? JobTypeId { get; set; }
}

这是来自 Elasticsearch 的响应(错误):

Failed to parse mapping [_doc]: Root mapping definition has unsupported parameters:

[ad : {
    properties= {
        landArea={
            type=long
        }, 
        isFurnished={
            type=boolean
        }, isActive={
            type=boolean
        }, title={
            search_analyzer=custom_english_analyzer, 
            analyzer=custom_english_analyzer, 
            type=text
        }, 
        availableFrom={
            type=date
        }, 
        mainPhotoUrl={
            index=false, 
            type=keyword
        }, 
        price={
            type=double
        }, 
        storeName={
            search_analyzer=custom_english_analyzer, 
            analyzer=custom_english_analyzer, 
            type=text
        }, 
        id={
            type=long
        }, 
        firstName={
            search_analyzer=custom_english_analyzer, 
            analyzer=custom_english_analyzer, 
            type=text
        }, 
        geoLocation={
            type=geo_point
        }
    }
}]

【问题讨论】:

  • 您不能将 Nest 弹性客户端与弹性 7 集群一起使用。删除类型后会发生一些重大变化。映射不再允许指定类型似乎官方弹性客户端的版本 7 存在 alpha:请参见此处:github.com/elastic/elasticsearch-net/tree/7.x
  • @PierreMallet:非常感谢。所以 ES 7 in out,但不支持使用 NEST(NEST 7 在 alpha 上)?听起来我最明智的选择是将我的 Elasticsearch 服务器降级回版本 6?
  • 我想是的。但我不是巢用户。也许其他人可以证实我的想法
  • 谢谢...我认为你是对的...我将我的 ES 降级到 6.8,它又开始工作了。
  • this

标签: elasticsearch nest


【解决方案1】:

您曾经使用 Elasticsearch 版本 6,现在使用版本 7。

我认为您的云 Elasticsearch 客户端版本仍然是版本 6。 这导致了您的错误。在 Elasticsearch 7 中,映射类型有 被移除。 https://www.elastic.co/guide/en/elasticsearch/reference/6.5/removal-of-types.html

也将您的云升级到版本 7。

【讨论】:

  • 感谢您的回答...我没有使用任何托管的 ES,我正在管理自己的服务器。正如 cmets 中所解释的那样,在提出这个问题时,ES 7 已经出局,但 NEST 在 6 上......我无法将 NEST 6 与 ES 7 一起使用......这就是问题所在。
猜你喜欢
  • 2019-09-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-12-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多