Paige Cook
Paige Cook

Reputation: 22555

Set analyzers for _all field with NEST

As described in the _all field Elasticsearch Documentation.

The _all fields allows for store, term_vector and analyzer (with specific index_analyzer and search_analyzer) to be set.

Is there a way to specify the index_analyzer and search_analyzer attributes on the _all field for a mapping with NEST? Specifically, I would like to be able to set the following for my index:

 {
     "model": {
        "_all": { 
             "index_analyzer": "nGram_analyzer",
             "search_analyzer": "whitespace_analyzer"
        }

       ...
  }

I did not see anything that would allow for this in the Fluent Mappings. Can I set this manually if not via Fluent Mapping?

Upvotes: 0

Views: 1479

Answers (1)

Martijn Laarman
Martijn Laarman

Reputation: 13536

Starting from NEST 1.0 you can now do this:

var result = this._client.Map<ElasticsearchProject>(m => m
    .AllField(a=>a
        .Enabled() 
        .IndexAnalyzer("nGram_analyzer")
        .SearchAnalyzer("whitespace_analyzer")
        .TermVector(TermVectorOption.with_positions_offsets)
    )
    ...
    ...

Upvotes: 3

Related Questions