简体   繁体   English

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

[英]Is there any way to see why my v7.6 Elasticsearch mapping isn't working and defaulting to the base mapping?

I'm upgrading my Elasticsearch project from v6.6 to v7.6.2.我正在将我的 Elasticsearch 项目从 v6.6 升级到 v7.6.2。 I use Elasticsearch.NET and NEST in order to create my index including mappings, settings, and to ingest my data into Elasticsearch from my SQL db.我使用 Elasticsearch.NET 和 NEST 来创建我的索引,包括映射、设置,并将我的数据从我的 SQL 数据库中提取到 Elasticsearch 中。

Everything works well in v6.6, but when I upgraded to v7.6.2, it no longer accepts my custom mappings and settings.在 v6.6 中一切正常,但是当我升级到 v7.6.2 时,它不再接受我的自定义映射和设置。 I'm referring to things like my nested objects, my custom analyzers, etc. The data does get ingested, but it defaults to the, well, default mapping (where mostly everything is a keyword or simple data type).我指的是我的嵌套对象、我的自定义分析器等。数据确实被摄取,但它默认为默认映射(其中大部分都是关键字或简单数据类型)。

This type of behavior normally happens when there's something syntactically wrong in your mappings or in your POCO.当您的映射或 POCO 中存在语法错误时,通常会发生这种类型的行为。 This isn't my case, I don't think.这不是我的情况,我不认为。

Is there some breaking change in v7.x that I may have missed? v7.x 中是否有一些我可能错过的重大变化? I've been through the documentation fairly extensively.我已经相当广泛地阅读了文档。

To give an example of what my mapping should look like, here's an excerpt (from my v6.6 cluster).为了举例说明我的映射应该是什么样子,这里有一段摘录(来自我的 v6.6 集群)。

...notice things like the 'products' object is of type: nested... ...注意“产品” object 之类的类型:嵌套...

[{"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":

and here's what it shows as the default version in v7.6.2...这是它在 v7.6.2 中显示为默认版本的内容...

...notice things like the 'products' object not nested, and lots of 'keyword' types, no custom analyzers, etc. ... ...注意诸如“产品”object 之类的东西没有嵌套,还有很多“关键字”类型,没有自定义分析器等...

    [{"_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":

As you may be able to notice, the v6.6 version is much more detailed and contains my nested objects, etc. But my v7.6.2 version contains the basic, default structure.您可能会注意到,v6.6 版本更详细,包含我的嵌套对象等。但我的 v7.6.2 版本包含基本的默认结构。

Something must be going wrong here but I don't know what.这里一定有问题,但我不知道是什么。

Is there some debug logging level that I can enable that will tell me why it's "failing"?是否有一些我可以启用的调试日志记录级别会告诉我为什么它“失败”?

UPDATE So I'm putting a slightly abbreviated version of how I'm mapping my objects and settings here.更新所以我在这里放了一个稍微简略的版本来说明我如何映射我的对象和设置。 Hopefully this helps to understand this issue.希望这有助于理解这个问题。

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
    }

I use two objects, one called Store24 which maps from the data returned from SQL and one called Product which creates the Elasticsearch mapping.我使用了两个对象,一个称为Store24 ,它映射从 SQL 返回的数据,另一个称为Product ,它创建 Elasticsearch 映射。

I figured out my own issue.我想出了我自己的问题。 It seems the creating of the index was throwing an error but I wasn't seeing it.似乎索引的创建引发了错误,但我没有看到它。 It was being 'hidden' by the response to the Indices.Create() returned object.它被对 Indices.Create() 返回的 object 的响应“隐藏”。 (the var indexCreate object in my sample above). (上面我的示例中的 var indexCreate object)。 Once I poked at it, the following error was being thrown: "Token filter [wordDelimiter] cannot be used to parse synonyms".一旦我戳它,就会抛出以下错误:“令牌过滤器 [wordDelimiter] 不能用于解析同义词”。

This was an issue in my settings - I guess a breaking change for 7.x that I didn't see.这是我的设置中的一个问题 - 我猜想 7.x 的重大变化是我没有看到的。 A rather complex issue actually.实际上是一个相当复杂的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM