有什么方法可以查看为什么我的v7.6 Elasticsearch映射不起作用并默认使用基本映射吗?

问题描述 投票:0回答:1

我正在将我的Elasticsearch项目从v6.6升级到v7.6.2。我使用Elasticsearch.NET和NEST来创建我的索引,包括映射,设置,并从我的SQL数据库将数据吸收到Elasticsearch中。

在v6.6中,一切都正常,但是当我升级到v7.6.2时,它不再接受我的自定义映射和设置。我指的是诸如嵌套对象,自定义分析器等之类的东西。虽然确实会吸收数据,但是它默认为默认映射(大多数情况下,所有内容都是关键字或简单数据类型)。

当您的映射或POCO在语法上有错误时,通常会发生这种类型的行为。我不认为这不是我的情况。

我可能错过了v7.x中的一些重大更改?我已经仔细阅读了文档。

[举例来说,这是我的v6.6集群的摘录。

...注意类似“产品”对象的类型为:嵌套...

[{"searchdata":{"_all":{"enabled":false},"properties":{"groupid":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"products":{"type":"nested","properties":{"adddate":{"type":"date"},"additionaltitles":{"type":"text"},"additionaltitleslist":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"adult":{"type":"integer"},"artists":{"properties":{"id":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"name":{"type":"text","norms":false,"fields":{"ci":{"type":"text","norms":false,"analyzer":"caseInsensitive"},"nc":{"type":"text","norms":false,"analyzer":"titleNoCharAnalyzer"},"raw":

这是它在v7.6.2中显示为默认版本的内容...

...注意诸如“产品”对象未嵌套,许多“关键字”类型,无自定义分析器等之类的东西。...

    [{"_doc":{"properties":{"groupid":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"products":{"properties":{"adult":{"type":"long"},"artists":{"properties":{"id":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"name":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"nameidsplit":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"nameremarticle":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}}}},"catalognum":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"costprice":{"type":"float"},"cover":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"credits":{"properties":{"id":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"name":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"nameidsplit":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"nameremarticle":{"type":"text","fields":

您可能会注意到,v6.6版本更加详细,并且包含我的嵌套对象等。但是我的v7.6.2版本包含基本的默认结构。

这里肯定有问题,但我不知道什么。

是否可以启用一些调试日志记录级别,该级别将告诉我为什么它“失败”?

UPDATE因此,我在此处略述了我如何映射对象和设置的方式。希望这有助于理解此问题。

var indexCreate = client.Indices.Create(indexName, nc => nc
.Settings(st => st
    .RefreshInterval(60) //slowing the refresh interval so we can get a running count
    .NumberOfReplicas(0) //must be set to refresh after created
    .NumberOfShards(numOfShards)
    .Analysis(a => a
        .Analyzers(an => an
            .UserDefined("fullTermCaseInsensitive", FullTermCaseInsensitive)
            .UserDefined("fullTerm", FullTerm)
            .UserDefined("caseInsensitive", CaseInsensitive)                      
        )
        .TokenFilters(tf => tf
            .UserDefined("syn", Syn)
            .UserDefined("myStopFilter", MyStopFilter)
            .UserDefined("wordDelimiter", WordDelimiter)                           
        )
    )
)
.Map<Store24>(m => m
    .Dynamic(false)

    .AutoMap()
    .Properties(props =>
    {
        SetPutMappingStore24(props); //see function below
        return props;
    })
));
       private static void SetPutMappingStore24(PropertiesDescriptor<Store24> pm)
       {
            pm.Nested<Product>(x => x
                .AutoMap()
                .Name(nm => nm.Products)
                .Properties(pr => pr
                    .Nested<StorePriceSplit>(sp => sp
                        .Name("storeprice").AutoMap()
                    )
                .Properties(props =>
                    {
                        SetPutMappingDescriptorTiWo(props, "tracks");
                        SetPutMappingDescriptorTiWo(props, "title");
                    }
                )
           );

       //...... more fluent mappings here
       }
    [ElasticsearchType(IdProperty = "Groupid")]
    public class Store24
    {
        /// <summary>
        /// Identifiers
        /// </summary>
        [Key]
        [Keyword]
        public string Groupid { get; set; }

        [JsonIgnore]
        public string Upc { get; set; }

        [JsonIgnore]
        public string Titleremarticle { get; set; }

        [Nested]
        [PropertyName("products")]
        public IEnumerable<Product> Products { get; set; }

    //... more properties here
    }
    [ElasticsearchType(RelationName = "product")]
    public class Product
    {
        [Key]
        [Text(Analyzer = "fullTermCaseInsensitive")]
        public string Upc { get; set; }

        [Text(Analyzer = "fullTermCaseInsensitive", Fielddata = true)]
        public string Titleremarticle { get; set; }

    //...more properties here
    }

我使用两个对象,一个称为Store24,它从SQL返回的数据进行映射,而另一个称为Product,它创建Elasticsearch映射。

elasticsearch nest elasticsearch-mapping elasticsearch.net
1个回答
0
投票
这是我设置中的一个问题-我想我没有看到7.x的重大更改。实际上是一个相当复杂的问题。
© www.soinside.com 2019 - 2024. All rights reserved.