elastic / elasticsearch-net

This strongly-typed, client library enables working with Elasticsearch. It is the official client maintained and supported by Elastic.

Home Page:https://www.elastic.co/guide/en/elasticsearch/client/net-api/current/index.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CreateIndexDescriptor Mappings -> Map Api usage issue

sbodese opened this issue · comments

NEST/Elasticsearch.Net version: 7.15.5

Elasticsearch version: 8.9.0

Description of the problem including expected versus actual behavior:

Steps to reproduce:

  1. use the CreateIndexDescriptor only to validate a mapping

new CreateIndexDescriptor(indexName).Mappings(md => md.Map<TDocument>(m => m.AutoMap(5)));

Or as the new API suggested:

new CreateIndexDescriptor(indexName).Map<TypeMappingDescriptor<TDocument>>(mp => mp.AutoMap(5));

expected is a IndexState object with a correct mapping.

  1. if i use these new API to create only (without settings) a Indexstate with a mapping, i got a empty mapping.

The same APi usage like

descriptor.InitializeUsing(indexState) .Settings(s => s.Setting(UpdatableIndexSettings.MaxNGramDiff, 3)) .Map<TypeMappingDescriptor<TDocument>>(mp => mp.AutoMap(5));
works correctly.

@flobernd Have you an idea please or is this a bug?

Further, i got a "strange" index response if i use the newer api call with this nest client 7.17.5, the delivered mappings doesnt contains the mapping field attribute "index=false" vs the older Mapping Function call

     `   return new CreateIndexDescriptor(indexName).Mappings(md => md.Map<TDocument>(m => m.AutoMap(5)));`

creates:

  "token": {
    "fields": {
      "keyword": {
        "ignore_above": 256,
        "type": "keyword"
      }
    },
    "type": "text"
  }

versus the expected JSON

{
  "token": {
    "index": false,
    "type": "text"
  },

it seems thats here is something wrong ?!