0
votes

I am using elasticsearch 6 nest for dot.net I used _all field in order to search all the index but now since its deprecated i need a new solution

I have found the copy_to option which is good enough.

My question is : i used to define to the _all field which analyzer it should use (ngram) and which search analyzer it should use (whitespace) for my project reasons.

Now since the copy_to field is not declared in the mappings i am unable to define it, any idea would be appreciated.

var res = client1.CreateIndex(INDEX_NAME, desc => desc
            .InitializeUsing(indexState)
             .Settings(x => x
                .Analysis(g => g
                    .Tokenizers(t => t
                        .NGram("ngram_tokenizer", y => y
                        .MinGram(3)
                        .MaxGram(7)
                        .TokenChars(
                            TokenChar.Letter,
                            TokenChar.Digit,
                            TokenChar.Punctuation,
                            TokenChar.Symbol
                        )))
                    .Analyzers(o => o
                        .Custom("ngram_analyzer", w => w.Tokenizer("ngram_tokenizer").Filters("lowercase"))
                        .Whitespace("whitespace_analyzer")
                        .Standard("standard_analyzer", e => e.MaxTokenLength(1111)))))
            .Mappings(ms => ms
                .Map<SampleClass>(m => m
                    .AutoMap() //Still auto map exists if there are attributes on the class definition
                    .Properties(ps => ps //Override auto map
                        .Text(s => s
                            .Name(n => n.SampleString)
                            .CopyTo(am=>am.Field("searchallfield")))
                        .Number(s => s
                            .Name(n => n.SampleInteger))
                        .Date(s => s
                            .Name(n => n.SampleDateTime)
                            .Format("MM-DD-YY"))
            ))));
1

1 Answers

1
votes

Apparently you can define the copy_to field in the mappings

                    .Map<SampleClass>(m => m
                    .AutoMap() //Still auto map exists if there are attributes on the class definition
                    .Properties(ps => ps //Override auto map
                        .Text(yy=>yy
                            .Name("searchallfield")
                            .SearchAnalyzer("whitespace_analyzer")
                            .Analyzer("ngram_analyzer"))
                        .Text(s => s
                            .Name(n => n.SampleString)
                            .CopyTo(am=>am.Field("searchallfield")))
                        .Number(s => s
                            .Name(n => n.SampleInteger))
                        .Date(s => s
                            .Name(n => n.SampleDateTime))