Mapping document indexing with NEST

I'm using .NET Core application with NEST client.
My goal is to index a model with few modifications in its properties, for example, this model contains list of objects, and I would like to document list of the Ids of the objects instead of the objects themselves.

So, I have made a test, I created a mapping, according to the information I have found over here:

var result = elasticClient.Indices.Create("change-log", c => c
    .Map<ChangeLog>(m => m
        .Properties(ps => ps
            .Text(s => s
                .Name(n => n.Source)
            )
            .Text(s => s
                .Name("test")
                )
        )
    )
);

After this code runs, I can see in Index Management - Mapping that my mapping was just created for 'change-log' index.

Right after the execution of the previous code I'm trying to index my model with the following code:

var indexResponse1 = elasticClient.Index(data, i => i.Index("change-log"));

The model inside data variable indexed regardless the mapping that was just created, and when I am looking again in Index Management - Mapping I can see that mapping was changed to the structure of the model held inside data variable.

What is wrong with my code? would be grateful for your help.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.