0

This is my NEST2.0 POCO declaration:

[ElasticsearchType(Name = "MyDocument")]
public class MyDocument: DynamicResponse
{
    [String(Store = false, Index = FieldIndexOption.NotAnalyzed)]
    public string HistoryId{ get; set; }

    [String(Store = false, Index = FieldIndexOption.NotAnalyzed)]
    public string FileId { get; set; }

    [Date(Store = false)]
    public DateTime DateTime { get; set; }
}

and this is the mapping for it:

            elastic.Map<MyDocument>(m => m
                .Index(indexName)
                .AutoMap().AllField(a => a.Enabled(false))
                .Dynamic()
                .DynamicTemplates(dt => dt
                    .Add(t => t
                        .Name("pv_values_template")
                        .Match("ch_*")
                        .Mapping(m2 => m2
                            .Number(n => n
                                .Store(false)
                                .Index(NonStringIndexOption.NotAnalyzed)
                                .DocValues(true))))));

Looks like the .Add() method doesn't exist anymore (it was working fine with NEST 1.0)

Gianluca Ghettini
  • 11,129
  • 19
  • 93
  • 159

1 Answers1

1

Add method has been renamed to DynamicTemplate and signature changed a bit, so take a look:

client.Map<Document>(m => m
    .Index(indexName)
    .AutoMap().AllField(a => a.Enabled(false))
    .Dynamic()
    .DynamicTemplates(dt => dt
        .DynamicTemplate("pv_values_template", t => t 
            .Match("ch_*")
            .Mapping(m2 => m2
                .Number(n => n
                    .Store(false)
                    .DocValues(true))))));

Probably you are asking where is .Index(NonStringIndexOption.NotAnalyzed) option in the new mapping. This issue has a really nice description, so please take a look.

Hope it helps.

Rob
  • 9,664
  • 3
  • 41
  • 43
  • Thanks @Rob. This partially solved my problem. I still get some issue when writing those documents using the bulk write. Please have a look here: http://stackoverflow.com/questions/35721566/bulk-write-on-elasticsearch-2-0-nest-2-0-throws-a-stackoverflow-exception – Gianluca Ghettini Mar 01 '16 at 11:24
  • I've just added an EDIT to my question here: http://stackoverflow.com/questions/35721566/bulk-write-on-elasticsearch-2-0-nest-2-0-throws-a-stackoverflow-exception – Gianluca Ghettini Mar 01 '16 at 12:04