elasticsearch - Elasticsearch 7:无法解析映射[_doc]:根映射定义具有不受支持的参数:

标签 elasticsearch nest

我的NEST代码曾经与Elasticsearch版本6一起使用,在Elastichsearch版本7中抛出以下错误:

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



我看过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
        }
    }
}]

最佳答案

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

I think your cloud Elasticsearch client version is still version 6. This is causing your error. In Elasticsearch 7, mapping types have been removed. https://www.elastic.co/guide/en/elasticsearch/reference/6.5/removal-of-types.html



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

关于elasticsearch - Elasticsearch 7:无法解析映射[_doc]:根映射定义具有不受支持的参数:,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56356594/

相关文章:

elasticsearch - 如何避免在提交对象时扩展映射

elasticsearch - ElasticSearch-无法过滤字符串数组

elasticsearch - 如何使minimum_should_match与嵌套映射一起使用?

elasticsearch - Elasticsearch Nest索引查询始终返回false

elasticsearch - 如何在Elasticsearch 7 NEST 7中设置 “max_result_window”

c# - 使用 NEST 将 List<object> 插入 Elasticsearch

c# - ElasticSearch搜索结果不佳

javascript - Elasticsearch Javascript 浏览器客户端

laravel - 使用Laradock运行Elastic Search

java - 需要帮助使用 Java 高级 REST 客户端批量 API 创建动态 Elasticsearch 索引